Java Webview内部弹出窗口android
嗨, 我有一个问题,如上图所示,在左边的webview中有一个按钮。当我点击按钮时,安卓系统中会出现一个弹出窗口。在弹出窗口中,我需要一个网络视图。 现在没有弹出窗口中的webview,一切正常 此弹出窗口由javascript接口调用Java Webview内部弹出窗口android,java,javascript,android,webview,popupwindow,Java,Javascript,Android,Webview,Popupwindow,嗨, 我有一个问题,如上图所示,在左边的webview中有一个按钮。当我点击按钮时,安卓系统中会出现一个弹出窗口。在弹出窗口中,我需要一个网络视图。 现在没有弹出窗口中的webview,一切正常 此弹出窗口由javascript接口调用 public class AppJavaScriptProxy { private Activity activity = null; public AppJavaScriptProxy() { } @Javascript
public class AppJavaScriptProxy {
private Activity activity = null;
public AppJavaScriptProxy() {
}
@JavascriptInterface
public String showMessage(String footNoteNo) {
Integer footNoteNoInt = Integer.parseInt(footNoteNo);
footnote = myDbHelper.getFootnote(chapterNumber, footNoteNoInt);
try {
LayoutInflater inflater = (LayoutInflater) HomeActivity.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.footnote_popup,
(ViewGroup) findViewById(R.id.popup_footnote));
popup = new PopupWindow(layout, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, true);
popup.showAtLocation(layout, Gravity.CENTER, 0, 0);
txt_footnote=(TextView) layout.findViewById(R.id.text_footnote);
txt_footnote.setTypeface(malayalamfont);
popup_close = (ImageButton) layout.findViewById(R.id.btn_close_popup);
txt_footnote.setText(footnote);
final WebView footnoteWView = (WebView) layout.findViewById(R.id.footnotePopupWebview);
footnoteWView.getSettings().setJavaScriptEnabled(true);
footnoteWView.loadUrl("file:///android_asset/www/footNotePopup.html");
footnoteWView.clearCache(true);
footnoteWView.setWebViewClient(new WebViewClient(){
public void onPageFinished(WebView view, String url){ footnoteWView.loadUrl("javascript:getFootnote('" + footnote + "')");
}
});
popup_close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popup.dismiss();
}
});
}
catch (Exception e) {
e.printStackTrace();
};
}
}
请帮助试试这个
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Title here");
WebView wv = new WebView(this);
wv.loadUrl("http:\\www.yourweb.com");
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
alert.setView(wv);
alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
alert.show();
试试这个
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Title here");
WebView wv = new WebView(this);
wv.loadUrl("http:\\www.yourweb.com");
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
alert.setView(wv);
alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
alert.show();
公共类列表扩展ActionBarActivity实现OnClickListener{
线性布局布局图;
弹出窗口弹出消息;
按钮弹出按钮;
网络视图弹出文本;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_列表);
init();
popupInit();
公共void init(){
popupButton=(按钮)findViewById(R.id.textview1);
popupText=新的网络视图(此);
setBackgroundColor(Color.TRANSPARENT);
字符串文本=“%s”;
String summary=“此处有一些文本”;
loadData(String.format(text,summary),“text/html”,“utf-8”);
popupText.setVerticalScrollBarEnabled(true);
popupText.setHorizontalScrollBarEnabled(true);
insidePopupButton=新按钮(此按钮);
insidePopupButton.setText(“(X)关闭”);
insidePopupButton.setBackgroundResource(R.drawable.myborder);
layoutOfPopup=新的线性布局(本);
LayoutParams lpView=新的LayoutParams(LayoutParams.WRAP_内容,
LayoutParams.WRAP_内容);
layoutOfPopup.addView(内部弹出按钮,lpView);
layoutOfPopup.addView(popupText);
layoutOfPopup.setOrientation(1);
layoutOfPopup.setBackgroundColor(颜色:白色);
}
public void popupInit(){
setOnClickListener(这个);
insidePopupButton.setOnClickListener(此);
popupMessage=新的PopupWindow(layoutOfPopup,
LayoutParams.MATCH_父级,LayoutParams.MATCH_父级);
setContentView(layoutOfPopup);
}
@凌驾
公共void onClick(视图v){
//代码位于此处,并以下拉方式打开显示
解雇
}
公共类列表扩展ActionBarActivity实现OnClickListener{
线性布局布局图;
弹出窗口弹出消息;
按钮弹出按钮;
网络视图弹出文本;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_列表);
init();
popupInit();
公共void init(){
popupButton=(按钮)findViewById(R.id.textview1);
popupText=新的网络视图(此);
setBackgroundColor(Color.TRANSPARENT);
字符串文本=“%s”;
String summary=“此处有一些文本”;
loadData(String.format(text,summary),“text/html”,“utf-8”);
popupText.setVerticalScrollBarEnabled(true);
popupText.setHorizontalScrollBarEnabled(true);
insidePopupButton=新按钮(此按钮);
insidePopupButton.setText(“(X)关闭”);
insidePopupButton.setBackgroundResource(R.drawable.myborder);
layoutOfPopup=新的线性布局(本);
LayoutParams lpView=新的LayoutParams(LayoutParams.WRAP_内容,
LayoutParams.WRAP_内容);
layoutOfPopup.addView(内部弹出按钮,lpView);
layoutOfPopup.addView(popupText);
layoutOfPopup.setOrientation(1);
layoutOfPopup.setBackgroundColor(颜色:白色);
}
public void popupInit(){
setOnClickListener(这个);
insidePopupButton.setOnClickListener(此);
popupMessage=新的PopupWindow(layoutOfPopup,
LayoutParams.MATCH_父级,LayoutParams.MATCH_父级);
setContentView(layoutOfPopup);
}
@凌驾
公共void onClick(视图v){
//代码位于此处,并以下拉方式打开显示
解雇
}
请提供有关您的问题的更多细节。请提供有关您的问题的更多细节。