Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7896425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:53:30+00:00 2026-06-03T07:53:30+00:00

I am trying to display a webview inside a custom dialog,its working outside the

  • 0

I am trying to display a webview inside a custom dialog,its working outside the dialog.Here is my code below along with xml of the custom dialog xml.Kindly give me your expertise on this ,thanks.

public class TellaFriend extends Activity {

static final int CUSTOM_DIALOG_ID = 0;
TextView customDialog_TextView;
EditText customDialog_EditText;
Button customDialog_Update, customDialog_Dismiss;;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button buttonStartDialog = (Button) findViewById(R.id.button1);
    buttonStartDialog.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(CUSTOM_DIALOG_ID);
        }
    });
}

private Button.OnClickListener customDialog_UpdateOnClickListener = new Button.OnClickListener() {
    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        String sharedFact = customDialog_EditText.getText().toString();
    }
};

private Button.OnClickListener customDialog_DismissOnClickListener = new Button.OnClickListener() {
    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        dismissDialog(CUSTOM_DIALOG_ID);
    }
};

@Override
protected Dialog onCreateDialog(int id) {
    // TODO Auto-generated method stub
    Dialog dialog = null;
    switch (id) {
    case CUSTOM_DIALOG_ID:

        dialog = new Dialog(this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setCancelable(false);
        dialog.setContentView(R.layout.customlayout);

        WebView webView = (WebView) findViewById(R.id.webview);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setBackgroundColor(Color.BLACK);
        webView.loadUrl("file:///android_asset/Help.html");

        webView.setWebViewClient(new GameClient());

        customDialog_Update = (Button) dialog.findViewById(R.id.submit);
        customDialog_Dismiss = (Button) dialog.findViewById(R.id.buttonone);

        customDialog_Update.setOnClickListener(customDialog_UpdateOnClickListener);     customDialog_Dismiss.setOnClickListener(customDialog_DismissOnClickListener);
        break;
    }
    return dialog;
}

public class GameClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}
}

and xml

<?xml version="1.0" encoding="utf-8"?>
RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="290dp" android:background="#ffffff" 
android:layout_height="350dp" >

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_margin="15dp"
    android:orientation="vertical"
    android:padding="2dp" >

    <ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scrollbarSize="12dip"
    android:scrollbarThumbVertical="@drawable/scrollbar_vertical_thumb"
    android:scrollbarTrackVertical="@drawable/scrollbar_vertical_track" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <WebView android:id="@+id/webview" android:layout_width="fill_parent"  
    android:layout_height="fill_parent" />

        </LinearLayout>        

            <Button
                android:id="@+id/backbtn" android:layout_marginTop="20dp"
                android:layout_width="165dp"
                android:layout_height="57dp"
                android:layout_gravity="center_horizontal"           
                android:text="Call and Talk with a buyer now"
                android:textColor="#000000"
                android:textSize="13sp"
                android:textStyle="bold" />

            <Button
                android:id="@+id/submit" android:layout_marginTop="20dp"
                android:layout_width="165dp"
                android:layout_height="57dp"
                android:layout_gravity="center_horizontal"                 
                android:text="Email Buyer now to confirm selling details"
                android:textColor="#000000"
                android:textSize="13sp"
                android:textStyle="bold" />       
    </LinearLayout>
</ScrollView>     
</RelativeLayout>
<RelativeLayout 
android:layout_width="290dp" android:background="@drawable/abg" 
android:layout_height="350dp" android:layout_margin="1dp">
<Button
    android:id="@+id/buttonone" 
    android:layout_width="25dp"
    android:layout_height="25dp"
    android:layout_alignParentRight="true"
    android:layout_margin="5dp"
    android:background="@drawable/round_button_background"
    android:gravity="center_vertical|center_horizontal"
    android:onClick="cancelActivity"
    android:text="X" 
    android:textColor="#ffffff"
    android:textSize="13sp"
    android:textStyle="bold" />

</RelativeLayout>
</RelativeLayout>

Error log is

05-02 10:00:04.922: E/AndroidRuntime(488): FATAL EXCEPTION: main
05-02 10:00:04.922: E/AndroidRuntime(488): java.lang.NullPointerException
05-02 10:00:04.922: E/AndroidRuntime(488):  at com.kk.TellaFriend.TellaFriend.onCreateDialog(TellaFriend.java:91)
05-02 10:00:04.922: E/AndroidRuntime(488):  at android.app.Activity.onCreateDialog(Activity.java:2472)
05-02 10:00:04.922: E/AndroidRuntime(488):  at android.app.Activity.createDialog(Activity.java:881)
05-02 10:00:04.922: E/AndroidRuntime(488):  at android.app.Activity.showDialog(Activity.java:2547)
05-02 10:00:04.922: E/AndroidRuntime(488):  at android.app.Activity.showDialog(Activity.java:2514)
05-02 10:00:04.922: E/AndroidRuntime(488):  at com.kk.TellaFriend.TellaFriend$3.onClick(TellaFriend.java:45)
05-02 10:00:04.922: E/AndroidRuntime(488):  at android.view.View.performClick(View.java:2408)
05-02 10:00:04.922: E/AndroidRuntime(488):  at android.view.View$PerformClick.run(View.java:8816)
05-02 10:00:04.922: E/AndroidRuntime(488):  at android.os.Handler.handleCallback(Handler.java:587)
05-02 10:00:04.922: E/AndroidRuntime(488):  at android.os.Handler.dispatchMessage(Handler.java:92)
05-02 10:00:04.922: E/AndroidRuntime(488):  at android.os.Looper.loop(Looper.java:123)
05-02 10:00:04.922: E/AndroidRuntime(488):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-02 10:00:04.922: E/AndroidRuntime(488):  at java.lang.reflect.Method.invokeNative(Native Method)
05-02 10:00:04.922: E/AndroidRuntime(488):  at java.lang.reflect.Method.invoke(Method.java:521)
05-02 10:00:04.922: E/AndroidRuntime(488):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-02 10:00:04.922: E/AndroidRuntime(488):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-02 10:00:04.922: E/AndroidRuntime(488):  at dalvik.system.NativeStart.main(Native Method)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:53:32+00:00Added an answer on June 3, 2026 at 7:53 am

    You will need to call findViewById for dialog.

    WebView webView = (WebView) dialog.findViewById(R.id.webview);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display a twitterBox inside a webview in a JavaFx 2.0
I want to display pdf contents on webview. Here is my code: WebView webview
I am trying to load URL inside a WebViewClient as below: webview.setWebViewClient(new WebViewClient() {
I'm trying to display an image in a WebView in an Android app. The
Ive been trying to display formatted content blocks from a xml file with no
In a nutshell, I'm trying to display an animated GIF in a webview. This
I'm trying to display a website inside my blackberry app but the browserfield is
i am trying to display html in webview but problem is it is showing
I’m trying to display a page of embed YouTube videos. I got the code
I'm currently trying to get a custom WebView that displays a ContextMenu when it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.