• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Perform Click on start of a Dialog

 
Ranch Hand
Posts: 79
Android Java ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a dialog called from Activity's onCreate. When the dialog opens, I want to perform a button click. I added btn_ok.performClick() in onStart() of the dialog. But I receive an Exception NullPointerException at Log.i statement of onClick(). If I remove that Log.i then it works and calls new LoginTask().execute.

In my onClick for that button code :


BUT the problem that I face is: If I click the button normally then the app shows the ProgressDialog (dialog = new ProgressDialog(mContext); // mContext is the context of main dialog) that is in onPre of LoginTask . But now, when I am performing the click programmatically from onStart(), I don't see the ProgressDialog. The doInBackground() work is appening (came to know from Logs) but their is no ProgressDialog to let the user know that the task has started.

It seems like this.getCurrentFocus().getId()); is throwing NullPointerException, so till onStart() is comlpeted, I don't have the focus and/or the id. Without that it can't have context to pass to the ProgressDialog and thus ProgressDialog is not showing or what ? These are just my thinkings based on logic.

How to overcome this problem ? Any help is highly appreciated.

 
Trupti Mehta
Ranch Hand
Posts: 79
Android Java ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[b]GOT IT .[/b]

Added onAttachedToWindow() method. Tested if I have getContext() in that and I do have. And I try to perform the button click and the LoginTask shows the ProgressDialog.

Thanks to all. This might help anyone who is trying somethng like me i.e. to perform a button click on start of a dialog and using its context.
reply
    Bookmark Topic Watch Topic
  • New Topic