open a custom dialog from a asnytask

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

open a custom dialog from a asnytask

Postby martini » Thu Sep 24, 2009 9:22 pm

hi

I try to open a custom dialog from a asnyctask. I dont get an exception, but the dialog just don't shows...
When i try it from the activity (per example from the onClick-method) the dialog shows without a problem. But when i first try it from the asynctask and then from the onClick-method it doesn't work anymore...

I followed this tutorial : http://developer.android.com/guide/topi ... stomDialog

my asnytask doInBackground method
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @Override
  3.  
  4. protected Object doInBackground(Object... params) {
  5.  
  6.   Looper.prepare(); // without this i got an exception, but i dont have a idea what's this for...
  7.  
  8.                        
  9.  
  10.   try {
  11.  
  12.     showDialog(0);
  13.  
  14.   } catch (Exception ex) {
  15.  
  16.     Log.e(Workout.class.getName(), ex.getMessage(), ex);
  17.  
  18.   }
  19.  
  20.   return null;
  21.  
  22. }
  23.  
  24.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


my onCreateDialog from the activity
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.     protected Dialog onCreateDialog(int id) {
  3.  
  4.         Dialog dialog = new Dialog(this);
  5.  
  6.  
  7.  
  8.         dialog.setContentView(R.layout.custom_dialog);
  9.  
  10.         dialog.setTitle("Custom Dialog");
  11.  
  12.        
  13.  
  14.         TextView text = (TextView) dialog.findViewById(R.id.text);
  15.  
  16.         text.setText("Hello, this is a custom dialog!");
  17.  
  18.         return dialog;
  19.  
  20.     }
  21.  
  22.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


has anybody ever tried something similar?

thx for any help

grz
martini
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Sep 24, 2009 9:03 pm
Location: ch

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests