Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid multiple dialogs under tabactivity showDialog(0)
    primarykey
    data
    text
    <p>I wanted to create a multiple Activitiy under tab dialog. But the problem is that when I press the button, I get the following error: and apps from bases.</p> <blockquote> <p>06-18 19:57:06.444 E / AndroidRuntime (1061): $ android.view.WindowManager BadTokenException: Unable to add window - token $ android.app.LocalActivityManager Local Activity Record @ 44f6a3e8 is not valid, is your activity running?</p> </blockquote> <p>Program is to <strong>showDialog(0)</strong>, and is accurate. I have searched long time but unfortunately I could not find the answer. Please help. How can I display a multiple Tabactivitiy dialogue. ?</p> <p><strong>Tabs Activity :</strong> </p> <pre><code>public class main extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Resources res = getResources(); TabHost tb = getTabHost(); TabHost.TabSpec spec; Intent inten; //tourism tab inten = new Intent().setClass(this, tum_yemekler.class); spec = tb.newTabSpec("tab1").setIndicator("Tüm Yemekler",res.getDrawable(R.drawable.hotel)) .setContent(inten); tb.addTab(spec); //hotel tab inten = new Intent().setClass(this, contactgroupeinkaufliste.class); spec = tb.newTabSpec("tab2").setIndicator("Yemek Bul",res.getDrawable(R.drawable.wisata)) .setContent(inten); tb.addTab(spec); //mall tab inten = new Intent().setClass(this, gunun_menusu.class); spec = tb.newTabSpec("tab3").setIndicator("Günün Menüsü",res.getDrawable(R.drawable.mall)) .setContent(inten); tb.addTab(spec); //restourant tab inten = new Intent().setClass(this, yardim.class); spec = tb.newTabSpec("tab4").setIndicator("Yardım",res.getDrawable(R.drawable.restoran)) .setContent(inten); tb.addTab(spec); tb.setCurrentTab(0); } } </code></pre> <p><strong>ActivityGroup :</strong></p> <pre><code>import java.util.ArrayList; import android.app.ActivityGroup; import android.content.Intent; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; public class contactgroupeinkaufliste extends ActivityGroup { View rootView; public static contactgroupeinkaufliste ContactGroupEinkaufliste_; sayilar ddsayilar ; private ArrayList&lt;View&gt; history1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.history1 = new ArrayList&lt;View&gt;(); ContactGroupEinkaufliste_ = this; View view = getLocalActivityManager().startActivity("CitiesActivity", new Intent(this,secimliyemek_main.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView(); // Replace the view of this ActivityGroup replaceView(view); } public void replaceView(View v) { // Adds the old one to history history1.add(v); // Changes this Groups View to the new View. setContentView(v); } public void back() { if(history1.size() &gt; 0) { history1.remove(history1.size()-1); if(history1.size()&lt;=0){ finish(); }else{ setContentView(history1.get(history1.size()-1)); } }else { finish(); } } @Override public void onBackPressed() { contactgroupeinkaufliste.ContactGroupEinkaufliste_.back(); } @Override public boolean onKeyDown(int keyCode, KeyEvent event){ if (keyCode == KeyEvent.KEYCODE_BACK){ contactgroupeinkaufliste.ContactGroupEinkaufliste_.back(); return true; } return super.onKeyDown(keyCode, event); } } </code></pre> <p><strong>Activity</strong></p> <pre><code>import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import android.app.Activity; import android.app.ActivityGroup; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class secimliyemek_main extends Activity { public static secimliyemek_main secimliyemek_main_; public static sayilar sayilarr; public static String baslik ; public static bilgideposu arraylistesi; public static String [] baharat ; public static String [] option; public static boolean[] _selections ; public static LinkedList&lt;String&gt; malzemeler =new LinkedList&lt;String&gt;(); protected Button Button_sebzeler; protected Button Button_baharatlar; protected Button Button_baklagiller; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.secimliyemek_main); Button_sebzeler = ( Button ) findViewById( R.id.sebzeler ); Button_sebzeler.setOnClickListener( new ButtonClickHandler_sebzeler() ); Button_baharatlar = ( Button ) findViewById( R.id.baharat ); Button_baharatlar.setOnClickListener( new ButtonClickHandler_baharat() ); Button_baklagiller = ( Button ) findViewById( R.id.baklagil); Button_baklagiller.setOnClickListener( new ButtonClickHandler_baklagiller() ); Button yemek_bul =(Button)findViewById(R.id.yemek_bul); yemek_bul.setOnClickListener(new OnClickListener() { public void onClick(View v) { View view1 = contactgroupeinkaufliste.ContactGroupEinkaufliste_.getLocalActivityManager().startActivity("secimliyemek_liste", new Intent("com.faqih.tutorialtab.SECIMLIYEMEK_LISTE") .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView(); // Replace the view of this ActivityGroup contactgroupeinkaufliste.ContactGroupEinkaufliste_.replaceView(view1); } }); } public class ButtonClickHandler_sebzeler implements View.OnClickListener { public void onClick( View view ) { option =arraylistesi.sebzeler; baslik = "Sebzeler"; boolean[] _selectionss = new boolean[ option.length ]; _selections=_selectionss; Button_sebzeler = ( Button ) findViewById( R.id.sebzeler ); //-------------- error comes from here -----------------???? showDialog(0); } } public class ButtonClickHandler_baharat implements View.OnClickListener { public void onClick( View view ) { option =arraylistesi.baharatlar; baslik = "Baharatlar"; boolean[] _selectionss = new boolean[ option.length ]; _selections=_selectionss; Button_baharatlar = ( Button ) findViewById( R.id.baharat ); showDialog(2); } } public class ButtonClickHandler_baklagiller implements View.OnClickListener { public void onClick( View view ) { option =arraylistesi.baklagiller; baslik = "Baklagiller"; boolean[] _selectionss = new boolean[ option.length ]; _selections=_selectionss; Button_baklagiller = ( Button ) findViewById( R.id.baklagil ); showDialog(3); } } @Override protected Dialog onCreateDialog( int id ) { final AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setMessage("Enter Holla message"); EditText hollaMessage = new EditText(this); dialog.setView(hollaMessage); dialog.setCancelable(false); dialog.setPositiveButton("Send", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { List result = new ArrayList(); } }); dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dismissDialog(0); } }); AlertDialog alert = dialog.create(); return alert; } public class DialogSelectionClickHandler implements DialogInterface.OnMultiChoiceClickListener { public void onClick( DialogInterface dialog, int clicked, boolean selected ) { printSelectedPlanets(selected,clicked); Toast.makeText(secimliyemek_main.this, clicked +" "+selected, Toast.LENGTH_SHORT).show(); } } public class DialogButtonClickHandler implements DialogInterface.OnClickListener { public void onClick( DialogInterface dialog, int clicked ) { switch( clicked ) { case DialogInterface.BUTTON_POSITIVE: closeContextMenu(); break; case DialogInterface.BUTTON_NEGATIVE: break; } } } protected void printSelectedPlanets(boolean clickedv, int clickedsv){ if(clickedv == true){ malzemeler.add(option[ clickedsv ]); Toast.makeText(secimliyemek_main.this, "eklenen: "+option[ clickedsv ] , Toast.LENGTH_SHORT).show(); } if(clickedv== false){ malzemeler.remove(option[ clickedsv]); Toast.makeText(secimliyemek_main.this, "cikarilan: "+option[ clickedsv ] , Toast.LENGTH_SHORT).show(); } } public boolean onKeyDown(int keyCode, KeyEvent event){ if (keyCode == KeyEvent.KEYCODE_BACK){ contactgroupeinkaufliste.ContactGroupEinkaufliste_. back(); return true; } return super.onKeyDown(keyCode, event); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload