java - Webview Inside popup window android - Stack Overflow

Hi,I have an issue as the above image shown, on the left there is a button inside a webview. When I cli

Hi, I have an issue as the above image shown, on the left there is a button inside a webview. When I click on button a popupwindow in android should be appeared. In that popup window i need a webview. now its all working fine without the webview in popup window.

this popup window is invoked by javascript interface

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();
        };
    }

}

please help

Hi, I have an issue as the above image shown, on the left there is a button inside a webview. When I click on button a popupwindow in android should be appeared. In that popup window i need a webview. now its all working fine without the webview in popup window.

this popup window is invoked by javascript interface

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();
        };
    }

}

please help

Share Improve this question edited Apr 15, 2015 at 14:48 jh314 27.9k16 gold badges66 silver badges83 bronze badges asked Apr 15, 2015 at 14:41 Mohd RiazMohd Riaz 234 silver badges9 bronze badges 1
  • Please provide more specifics as to what your problem is. – Necreaux Commented Apr 15, 2015 at 14:44
Add a ment  | 

2 Answers 2

Reset to default 6

Try this.

AlertDialog.Builder alert = new AlertDialog.Builder(this); 
alert.setTitle("Title here");

WebView wv = new WebView(this);
wv.loadUrl("http:\\www.yourweb.");
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();
public class List extends ActionBarActivity implements OnClickListener {
LinearLayout layoutOfPopup;
PopupWindow popupMessage;
Button popupButton;
WebView popupText;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);
init();
popupInit();
public void init() {
    popupButton = (Button) findViewById(R.id.textview1);
    popupText = new WebView(this);
    popupText.setBackgroundColor(Color.TRANSPARENT);
    String text = "<html><body style=\"text-align:justify\"> %s </body></Html>";
    String summary = "Some text go here</body></html>";
    popupText.loadData(String.format(text, summary), "text/html", "utf-8");
    popupText.setVerticalScrollBarEnabled(true);
    popupText.setHorizontalScrollBarEnabled(true);
    insidePopupButton = new Button(this);
    insidePopupButton.setText("(X)Close");
    insidePopupButton.setBackgroundResource(R.drawable.myborder);
    layoutOfPopup = new LinearLayout(this);

    LayoutParams lpView = new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);

    layoutOfPopup.addView(insidePopupButton, lpView);
    layoutOfPopup.addView(popupText);
    layoutOfPopup.setOrientation(1);
    layoutOfPopup.setBackgroundColor(Color.WHITE);
}

public void popupInit() {
    popupButton.setOnClickListener(this);
    insidePopupButton.setOnClickListener(this);
    popupMessage = new PopupWindow(layoutOfPopup,
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    popupMessage.setContentView(layoutOfPopup);

}
@Override
public void onClick(View v) {
    //Code goes here and to open the show as drop down
and dismiss
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745547901a4632426.html

相关推荐

  • java - Webview Inside popup window android - Stack Overflow

    Hi,I have an issue as the above image shown, on the left there is a button inside a webview. When I cli

    10小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信