AlertDialog.Builder builder = new AlertDialog.Builder(context);?
// use a custom View defined in xml?
View view = LayoutInflater.from(context).inflate(R.layout.my_custom_view);?
final EditText editText = (EditText)view.findViewById(R.id.edit_text);?
builder.setView(view);?
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {?
? ? @Override?
? ? public void onClick(DialogInterface dialog, int which) {?
? ? ? ? CharSequence userInput = editText.getText();?
? ? ? ? // do whatever you want with the input?
? ? }?
});?
AlertDialog alertDialog = builder.create();?
?
2.
final Context myApp = this; ?
final class MyWebChromeClient extends WebChromeClient {?
? ? @Override?
? ? public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {?
? ? ? ? new AlertDialog.Builder(myApp)?
? ? ? ? .setTitle("App Titler")?
? ? ? ? .setMessage(message)?
? ? ? ? .setPositiveButton(android.R.string.ok,?new DialogInterface.OnClickListener()?
? ? ? ? {?
? ? ? ? ? ? public void onClick(DialogInterface dialog, int which)?
? ? ? ? ? ? {?
? ? ? ? ? ? ? ? result.confirm();?
? ? ? ? ? ? }?
? ? ? ? })?
? ? ? ? .setNegativeButton(android.R.string.cancel,?
? ? ? ? ? ? ? ? new DialogInterface.OnClickListener()?
? ? ? ? {?
? ? ? ? ? ? public void onClick(DialogInterface dialog, int which)?
? ? ? ? ? ? {?
? ? ? ? ? ? ? ? result.cancel();?
? ? ? ? ? ? }?
? ? ? ? })?
? ? ? ? .create()?
? ? ? ? .show();?
?
? ? ? ? return true;?
? ? }?
}?
? ? ? ? ? ? ? ?
mWebView.setWebChromeClient(new MyWebChromeClient());?