Note that there are some explanatory texts on larger screens.

plurals
  1. POOpen a TabActivity with "simple" Activity
    primarykey
    data
    text
    <p>I have a problem when I try to open a TabActivity with an intent from an Activity.</p> <p>The code of my activity (ConnexionActivity), which is NOT an activity from a tab :</p> <pre><code> buttonConnexion.setOnClickListener(new OnClickListener(){ public void onClick(View v) { Intent intent = new Intent(ConnexionActivity.this, NeurokiffMobileActivity.class); startActivity(intent); } }); </code></pre> <p>and the TabActivity (NeurokiffMobileActivity) :</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); this.getIntent(); /* ******** Gestion Onglets ******** */ res = getResources(); // Resource object to get Drawables tabHost = (TabHost) findViewById(android.R.id.tabhost); // The activity TabHost /* *** Onglet "Evènements" *** */ /* Intent responsable de lancer l'activité depuis l'onglet */ intent = new Intent().setClass(this, EvenementActivity.class); bundleEnvoye.putString("id_user", idUser); intent.putExtras(bundleEnvoye); /* Crée un TabSpec et l'ajoute au TabHost */ spec = tabHost.newTabSpec("evenement").setIndicator("Evenements", res.getDrawable(R.drawable.ic_tab_evenement)) .setContent(intent); tabHost.addTab(spec); /* *** Onglet "Favoris" *** */ intent = new Intent().setClass(this, FavorisActivity.class); bundleEnvoye.putString("id_user", idUser); intent.putExtras(bundleEnvoye); spec = tabHost.newTabSpec("favoris").setIndicator("Favoris", res.getDrawable(R.drawable.ic_tab_favoris)) .setContent(intent); tabHost.addTab(spec); /* *** Onglet "Kiffs" *** */ intent = new Intent().setClass(this, KiffsActivity.class); bundleEnvoye.putString("id_user", idUser); intent.putExtras(bundleEnvoye); spec = tabHost.newTabSpec("kiffs").setIndicator("Kiffs", res.getDrawable(R.drawable.ic_tab_kiffs)) .setContent(intent); tabHost.addTab(spec); tabHost.setCurrentTab(0); } </code></pre> <p>and the .xml of this TabActivity :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:padding="5dp" /&gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0"/&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; </code></pre> <p>The error is a NullPointerException on the onCreate method of NeurokiffMobileActivity, and the application close. When I put another "simple" Activity instead of NeurokiffMobileActivity in the intent, it works.</p> <p>Can someone help me, please ? It seems to be a problem due to TabActivity, but I don't know which...</p> <p>Thanks in advance ! ;)</p>
    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.
    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