Hi Treking,
I have tried as you have suggested but not able to get the value.
May be i missing something.
Here is my code:


public class GetDialog extends Activity
{


        public void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                Button valueButton = (Button) findViewById(R.id.viewButton);
                valueButton.setOnClickListener(new OnClickListener() {
                   public void onClick(View v) {
                showDialog(0);
               }
             });

        }

        protected Dialog onCreateDialog(int id) {

                LayoutInflater factory = LayoutInflater.from(this);
        final View textEntryView = factory.inflate
(R.layout.viewlayout, null);

        return new AlertDialog.Builder(this)
            .setIcon(R.drawable.view)
            .setTitle("Enter Value")
            .setView(textEntryView)
            .setPositiveButton("OK", new
DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int
whichButton) {
                        EditText valueText = (EditText) findViewById
(R.id.viewText);
                        getvalue(valueText );
                }
            })
            .setNegativeButton("Cancel", new
DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int
whichButton) {

                }
            })
            .create();

        }

        void getvalue(EditText val)
        {
           try{
                        String value= val.getText().toString();
                        Log.i("Value ",value);
          }catch(Exception e){
               Log.i("Error", e.toString() );
               }
        }

}

It gives me error as: Java.lang.NullPointerException

please suggest.

Thanks



On Jan 5, 11:45 pm, TreKing <treking...@gmail.com> wrote:
> Another (simpler) option:
> - Add a click listener to you dialog
> - When it fires, get the EditText from the dialog (it's passed in as a
> parameter to the listener)
> - Get the text from the EditText object and pass it to the TextView (which I
> assume you have / can get a reference to) since it's in the same actitivty
> - Profit
>
> -------------------------------------------------------------------------------------------------
> TreKing - Chicago transit tracking app for Android-powered 
> deviceshttp://sites.google.com/site/rezmobileapps/treking
>
> On Tue, Jan 5, 2010 at 1:10 AM, Lenea <danmo...@gmail.com> wrote:
> > I've got it done. I just created a new class and set the Theme to
> > @android:style/Theme.Dialog, then i created an intent and called
> > startActivityForResult() and
> > passed the parameters through Bundle. hope this helps others with the
> > same problem as me
>
> > Cheers,
> > Lenea
>
> > On Jan 5, 8:48 am, Kevin Duffey <andjar...@gmail.com> wrote:
> > > If the dialog you open is to return a value, I forget the call.. still
> > > learning myself.. I think it's like onWaitForDialog or something. You can
> > > have it return a response to the activity that displayed it, which would
> > > probably be the same activity you want to update the textview with. Just
> > > update the textview, possibly in a thread to update the UI with the
> > > response.
>
> > > On Mon, Jan 4, 2010 at 10:29 PM, Justin Anderson <
> > janderson....@gmail.com>wrote:
>
> > > > There are several methods available for dealing with dialogs within an
> > > > activity...  Have a look at onCreateDialog(), onPrepareDialog(),
> > > > showDialog(), and removeDialog():
>
> > > >http://developer.android.com/reference/android/app/Activity.html#onCr.
> > ..
>
> > > > Thanks,
> > > > Justin
>
> > > > ----------------------------------------------------------------------
> > > > There are only 10 types of people in the world...
> > > > Those who know binary and those who don't.
> > > > ----------------------------------------------------------------------
>
> > > > On Sat, Jan 2, 2010 at 6:55 AM, Lenea <danmo...@gmail.com> wrote:
>
> > > >> Hello, everyone.
> > > >> I've got an application in which a button triggers a custom dialog.
> > > >> In the custom dialog i have an EditText.
> > > >> I want to collect data from the EditText and set the text of a
> > > >> TextView to that data.
> > > >> The problem is, the TextView is located in my main Activity(the one
> > > >> which triggered the custom dialog)
> > > >> How do I do that?
>
> > > >> Cheers,
> > > >> Lenea
>
> > > >> --
> > > >> You received this message because you are subscribed to the Google
> > > >> Groups "Android Beginners" group.
>
> > > >> NEW! Try asking and tagging your question on Stack Overflow at
> > > >>http://stackoverflow.com/questions/tagged/android
>
> > > >> To unsubscribe from this group, send email to
> > > >> android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com>
> > <android-beginners%2bunsubscr...@googlegroups.com<android-beginners%252bunsubscr...@googlegroups.com>
>
> > > >> For more options, visit this group at
> > > >>http://groups.google.com/group/android-beginners?hl=en
>
> > > >  --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Beginners" group.
>
> > > > NEW! Try asking and tagging your question on Stack Overflow at
> > > >http://stackoverflow.com/questions/tagged/android
>
> > > > To unsubscribe from this group, send email to
> > > > android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com>
> > <android-beginners%2bunsubscr...@googlegroups.com<android-beginners%252bunsubscr...@googlegroups.com>
>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-beginners?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Beginners" group.
>
> > NEW! Try asking and tagging your question on Stack Overflow at
> >http://stackoverflow.com/questions/tagged/android
>
> > To unsubscribe from this group, send email to
> > android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/android-beginners?hl=en
-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to