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

  • Home
  • SEARCH
  • 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 3968610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:51:50+00:00 2026-05-20T03:51:50+00:00

I have the following code for my dialog box, I want to get some

  • 0

I have the following code for my dialog box, I want to get some text from the alert box, but the below given code throws null pointer exception.

public EditText summarytext;
public Button done;
Context mContext = getApplicationContext();
    Dialog dialog = new Dialog(mContext);
    dialog.setContentView(R.layout.summaryalert);
    dialog.setTitle("Other");

    done=(ButtonfindViewById(R.id.btn);
    done.setOnClickListener(don);<----Nullpointer Exception


     private View.OnClickListener don=new  View.OnClickListener() {
                 @Override          
public void onClick(View v) {
                    // TODO Auto-generated method stub
                    if(v==findViewById(R.id.btn)){
                    summarytext=(EditText)findViewById(R.id.summarytext);
                    sumry=summarytext.getText().toString();
                    String display=""+sumry;
                    Toast toast = Toast.makeText(getBaseContext(),
     display, Toast.LENGTH_LONG);
                    toast.show();
                    }


summary alert

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widget31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000000"
android:gravity="center"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TableRow
android:id="@+id/widget60"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
>
<TextView
android:id="@+id/text"
android:text="Other(provide summary)"
android:textColor="#ffffff"
></TextView></TableRow>
<TableRow
android:id="@+id/widget60"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
>
<EditText
android:id="@+id/summarytext" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
>
</EditText>
</TableRow>
<TableRow
android:id="@+id/widget60"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
>
<Button
android:id="@+id/btn"
android:text="Done"
></Button>
</TableRow>

mainlayout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widget31"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffffff"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TableLayout
android:id="@+id/widget58"
android:layout_width="320px"
android:layout_height="65px"
android:orientation="vertical"
>
<TableRow
android:id="@+id/widget60"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
>
<EditText
android:id="@+id/other" 
android:layout_height="fill_parent" 
android:layout_width="fill_parent" 
android:ems="15">
</EditText>
</TableRow>
<TableRow
android:id="@+id/widget42"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:gravity="center"
>
<Button
android:id="@+id/submit"
android:layout_width="155px"
android:layout_height="41px"
android:text="Done"
android:layout_x="77px"
android:layout_y="313px"
>
</Button>
</TableRow>>
</TableLayout>

Edit

solved..!

include ‘dialog’

done=(Button)dialog.findViewById(R.id.btn);

  • 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-05-20T03:51:50+00:00Added an answer on May 20, 2026 at 3:51 am

    Try using dialog.findViewById(r.id.summarytext) you should also probably be using this for your done button also. But you’ll have to make the call for that after your dialog.show(). On a side note you can use getApplicationContext() for your Toast instead of getBaseContext().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML code for dialog box: <div id=modal-dialog class=no-display> <div class=form>
I have the following code that I use to create a dialog box: (function
I have got the following code to show a dialog box when the image
I have been using JQuery UI dialog box.The following code I am using.Can any
Have the following code which (resides in a dialog box) and serves as an
We have following code: try { // some code throwing MyException } catch (MyException
I have a legacy application that, at some point, generates the following code in
The following code will produce a truely model dialog box, with close button. Truely
I have a dialog box that displays a dynamic-sized form. I currently get the
I'm using the following code to create a Dialog box using JQUERY/UI: var $dialog2

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.