Android 我们可以在警报对话框中使用资产html文件吗?

Android 我们可以在警报对话框中使用资产html文件吗?,android,android-alertdialog,about-box,Android,Android Alertdialog,About Box,目前我正在使用字符串在警报对话框中显示文本,是否有一种方法可以直接使用资产html文件而不使用布局和显示警报对话框,如下面的代码 private void About() { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getString(R.string.about)); alertDialog.setMessage(getString(R

目前我正在使用字符串在警报对话框中显示文本,是否有一种方法可以直接使用资产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();
}
这样试试看

 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);
        }

您可以使用webview加载html文件的coustem dailog框,但我看不到任何涉及资产的内容。我看不到您希望在何处使用资产文件中的内容。请说得准确些。@Naveen你怎么能给我看一本书example@greenapps我刚刚给出了一个我现在正在使用的代码,并显示字符串中的文本。@Cervo让你知道androidi中的Custeam Dailog,我只是显示字符串中的文本,而没有使用任何文本视图或布局。在您建议的代码中,我看到这个TextView tv=(TextView)findViewById(R.id.text);tv.setText(文本);我不明白