how to get a AlertDialog in a Thread?

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

how to get a AlertDialog in a Thread?

Postby Arnold » Tue Mar 24, 2009 12:31 pm

i don't know where i made a mistake
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class Test extends Activity {
  3.  
  4.  
  5.  
  6.     @Override
  7.  
  8.     protected void onCreate(Bundle savedInstanceState) {
  9.  
  10.         super.onCreate(savedInstanceState);
  11.  
  12.         setContentView(R.layout.main);
  13.  
  14.         new Thread (){
  15.  
  16.                 public void run(){
  17.  
  18.                 new AlertDialog.Builder(Test.this).setTitle("Hello")
  19.  
  20.                        .setMessage("You get it")
  21.  
  22.                        .setPositiveButton("Restart", new DialogInterface.OnClickListener() {
  23.  
  24.                                      public void onClick(DialogInterface dialog, int whichButton){                      
  25.  
  26.                                           }
  27.  
  28.                                      })
  29.  
  30.                    .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  31.  
  32.                                         public void onClick(DialogInterface dialog, int whichButton){
  33.  
  34.                                                      finish();}
  35.  
  36.                                       }).show();
  37.  
  38.                 }
  39.  
  40.     }.start();
  41.  
  42.     }
  43.  
  44.    
  45.  
  46. }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
Arnold
Freshman
Freshman
 
Posts: 3
Joined: Fri Mar 13, 2009 10:11 am

Top

Postby wiederke » Tue Mar 24, 2009 2:39 pm

Hi,

why do you create a separate Thread for displaying a AlertDialog?


Cheers,

Torsten
wiederke
Experienced Developer
Experienced Developer
 
Posts: 72
Joined: Mon Mar 02, 2009 6:46 pm
Location: Germany

Postby Arnold » Tue Mar 24, 2009 3:39 pm

wiederke wrote:Hi,

why do you create a separate Thread for displaying a AlertDialog?


Cheers,

Torsten

:D i just wanna try this method.
Arnold
Freshman
Freshman
 
Posts: 3
Joined: Fri Mar 13, 2009 10:11 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests