Android WebView的使用
2010-07-19 23:13:00 来源:WEB开发网//构建一个Builder来显示网页中的alert对话框
Builder builder = new Builder(Test.this);
builder.setTitle("提示对话框");
builder.setMessage(message);
builder.setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
result.confirm();
}
});
builder.setCancelable(false);
builder.create();
builder.show();
return true;
}
public boolean onJsConfirm(WebView view,String url,String message,final JsResult result){
Builder builder = new Builder(Test.this);
builder.setTitle("带选择的对话框");
builder.setMessage(message);
builder.setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
result.confirm();
}
});
builder.setNeutralButton(android.R.string.cancel, new AlertDialog.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
result.cancel();
}
});
builder.setCancelable(false);
builder.create();
builder.show();
return true;
}
public boolean onJsPrompt(WebView view,String url,String message,String defaultValue,final JsPromptResult result){
LayoutInflater inflater = LayoutInflater.from(Test.this);
final View v = inflater.inflate(R.layout.prom_dialog, null);
//设置 TextView对应网页中的提示信息
((TextView)v.findViewById(R.id.TextView_PROM)).setText(message);
更多精彩
赞助商链接