android在对话框中加载webview

d-m*_*man 2 android dialog webview

我想在我的webview中打开twitter auth而不是在浏览器中打开,任何好的教程如何在对话框中使用webview并将其加载到对话框中?

Kon*_*rov 6

您只需将对话框主题应用于包含WebView的常规活动即可.


小智 5

  Context mContext = this;
  AlertDialog.Builder alert = new AlertDialog.Builder(mContext);

  alert.setTitle("Riga");
  WebView wv = new WebView(mContext);
  String html = "<html><body>some html here</body></html>";

  wv.loadData(html, "text/html", "UTF-8");
  alert.setView(wv);
  alert.setIcon(R.drawable.icon);
  alert.setPositiveButton("Yes", new DialogInterface.OnClickListener(){
     public void onClick(DialogInterface dialog, int id){
        Toast.makeText(getApplicationContext(), "Success", Toast.LENGTH_SHORT).show();
     }
  });
  alert.setNegativeButton("No", new DialogInterface.OnClickListener(){
     public void onClick(DialogInterface dialog, int id){
        Toast.makeText(getApplicationContext(), "Fail", Toast.LENGTH_SHORT).show();
     }
  });
  alert.show();
Run Code Online (Sandbox Code Playgroud)