2014-11-22 8 views
0

В настоящее время я использую строку, чтобы показать текст в окне предупреждения, есть ли способ использовать средства HTML файлов непосредственно, без использования макета и показать диалог предупреждения, как этот кодМожем ли мы использовать html-файлы активов в диалоговом окне «Предупреждение»?

private void About() { 
    AlertDialog alertDialog = new AlertDialog.Builder(this).create(); 
    alertDialog.setTitle(getString(R.string.about)); 
    alertDialog.setMessage(getString(R.stringabout)); 
    alertDialog.setIcon(R.drawable.ic_launcher); 
    alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, 
      getString(R.string.lbl_dialog_close), 
      new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int which) { 
        close 
       } 
      }); 
    alertDialog.show(); 
} 
+0

u можно использовать, но для этого купона dailog box с веб-просмотром, что webview загружает html-файл –

+0

Извините, но я не вижу ничего, что относится к активам. И я не вижу, где вы хотите использовать контент из файла активов. Пожалуйста, будьте точны. – greenapps

+0

@Naveen Как вы можете показать мне пример – Cervo

ответ

0

попробовать этот способ,

try { 
      InputStream is = getAssets().open("yourhtmlfile.txt"); 

      // We guarantee that the available method returns the total 
      // size of the asset... of course, this does mean that a single 
      // asset can't be more than 2 gigs. 
      int size = is.available(); 

      // Read the entire asset into a local byte buffer. 
      byte[] buffer = new byte[size]; 
      is.read(buffer); 
      is.close(); 

      // Convert the buffer into a string. 
      String text = new String(buffer); 

      // Finally stick the string into the text view. 
      TextView tv = (TextView)findViewById(R.id.text); 
      tv.setText(text); 
     } catch (IOException e) { 
      // Should never happen! 
      throw new RuntimeException(e); 
     } 
+0

Я просто показываю текст из строк и не использую никакого текстового вида или макета. в предлагаемом коде я вижу этот TextView tv = (TextView) findViewById (R.id.text); tv.setText (текст); которые я не понимаю – Cervo

 Смежные вопросы

  • Нет связанных вопросов^_^