Problème affichage onglet
Bonjour,
Dans l'application que je développe actuellement, je dois afficher une fenêtre avec des onglets. L'affichage des onglets fonctionne, mais le contenu qui devrait y être n'est pas affiché.
Code XML de l'interface contenant le TabHost
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| <?xml version="1.0" encoding="utf-8"?>
<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" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</FrameLayout>
</LinearLayout>
</TabHost> |
Code Java de l'activité
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| import android.app.*;
import android.content.Intent;
import android.os.*;
import android.view.View;
import android.widget.*;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.TabHost.TabSpec;
@SuppressWarnings("deprecation")
public class ConfigurationActivity extends TabActivity{
private TabHost tabhost;
private TabSpec tabspec;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.configuration);
Intent intent = new Intent(this, ConfigOngletUn.class);
tabhost = getTabHost();
tabspec = tabhost.newTabSpec("lidar").setIndicator("Lidar").setContent(intent);
tabhost.addTab(tabspec);
tabspec = tabhost.newTabSpec("gps").setIndicator("GPS").setContent(intent);
tabhost.addTab(tabspec);
tabspec = tabhost.newTabSpec("camera").setIndicator("Camera").setContent(intent);
tabhost.addTab(tabspec);
Spinner spinnerLidar = (Spinner)findViewById(R.id.spinnerNumeroLidar);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.lidar_array, android.R.layout.simple_spinner_dropdown_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerLidar.setAdapter(adapter);
}
} |
Code java contenant l'affichage du 1er onglet, les 2 autres étant similaires
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
public class ConfigOngletUn extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.configongletun);
String valeur1 = getIntent().getStringExtra("valeur1");
String valeur2 = getIntent().getStringExtra("valeur2");
String valeur3 = getIntent().getStringExtra("valeur3");
String valeur4 = getIntent().getStringExtra("valeur4");
TextView textview1 = (TextView)findViewById(R.id.textViewLidarNum);
textview1.setText(valeur1);
TextView textview2 = (TextView)findViewById(R.id.textViewPortComLidar);
textview2.setText(valeur2);
TextView textview3 = (TextView)findViewById(R.id.textViewVitesseLidar);
textview3.setText(valeur3);
TextView textview4 = (TextView)findViewById(R.id.textViewBitDonnees);
textview4.setText(valeur4);
}
} |