Ich versuche, eine einfache Registerkarte App in Android mit zwei Tabs zu tun. Mein Problem ist, dass, wenn ich diesen Code, in der Registerkarte, nur den Text, aber nicht die Symbole angezeigt wird. Wenn ich den Text auf "" setze, wird das Symbol angezeigt.Tab-Symbol nicht angezeigt
Kann mir jemand helfen? Meine Android-Version ist 4.0.3.
Vielen Dank.
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+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" >
<TabWidget android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@android:id/tabs" />
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@android:id/tabcontent" >
<LinearLayout android:id="@+id/tab1"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="@+id/textView1"
android:text="Contenido Tab 1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:id="@+id/tab2"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="@+id/textView2"
android:text="Contenido Tab 2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
und der Aktivitätscode ist
public class TabTestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabs=(TabHost)findViewById(R.id.tabhost);
tabs.setup();
TabHost.TabSpec spec=tabs.newTabSpec("mitab1");
spec.setContent(R.id.tab1);
spec.setIndicator("sss",
res.getDrawable(android.R.drawable.ic_btn_speak_now));
tabs.addTab(spec);
spec=tabs.newTabSpec("mitab2");
spec.setContent(R.id.tab2);
spec.setIndicator("TAB2",
res.getDrawable(android.R.drawable.ic_dialog_map));
tabs.addTab(spec);
tabs.setCurrentTab(0);
}
wie Sie ist sehr einfach zu sehen. Aber wenn ich schreibe spec.setIndicator("", res.getDrawable(android.R.drawable.ic_dialog_map));
kann ich das Symbol sehen, bu, wenn ich spec.setIndicator("TAB2", res.getDrawable(android.R.drawable.ic_dialog_map));
schreiben Ich kann nur TAB2 sehen, aber nicht beide von ihnen.
Es scheint, dass es keinen großen Raum gibt, beides zu zeigen. Also habe ich versucht, die Tab-Höhe mit diesem
tabs.getTabWidget().getChildAt(1).getLayoutParams().height = 150;
zu erhöhen, aber scheint nicht zu funktionieren.
könnten Sie ein bisschen mehr erklären? Ich verstehe nicht, wenn Sie überladen sagen? Vielen Dank – theholy
Dies funktioniert nicht für mich –