アセットフォルダーからカスタムダイアログボックスにhtmlファイルを表示しようとしています。しかし、エラーが発生します。次のコードを使用しています。
私のカスタム ダイアログ クラス
public class RobozoxDialog extends Activity{
Dialog my;
public RobozoxDialog(Context theContext){
my= new Dialog(theContext);
}
public void showRobozoxDialog(){
my.show();
}
public void setSource(String title,String url) {
WebView myWebView = (WebView) findViewById(R.id.webview_dialog);
myWebView.loadUrl(url);
my.setTitle(title);
}
}
カスタム ダイアログ XML
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview_dialog"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</WebView>
呼び出しダイアログ このように。
RobozoxDialog d = new RobozoxDialog(MainActivity.this);
d.setSource("Test", "file:///android_asset/test.html");
d.showRobozoxDialog();
しかし、エラーが発生し、問題を解決できません。メイン アクティビティ xml の webview で html ファイルを表示すると、それが表示されます。しかし、ダイアログwebviewに表示しようとすると、動作しなくなります..