2014-11-22 3 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는 사용할 수 있지만이 coustem dailog 상자 webview 그 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 (text); 나는 이해하지 못한다. – Cervo