我开始使用Android,当我尝试使用图标和文本进行TabHost时.只有文本可见,如果我将文本留空,则可以看到图标.我想在屏幕上看到两个.
有人可以给我建议吗?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Usuario usu = new Usuario();
usu.nombre = "fsdf";
lista.add(usu);
adaptador = new AdaptadorCelda(this,lista);
ListView lstView = (ListView)findViewById(R.id.lista);
lstView.setAdapter(adaptador);
Button btn = (Button)findViewById(R.id.btnSalva);
btn.setOnClickListener(onSave);
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("",res.getDrawable(android.R.drawable.ic_menu_rotate));
tabs.addTab(spec);
spec=tabs.newTabSpec("mitab2");
spec.setContent(R.id.tab2);
spec.setIndicator("ddd",
res.getDrawable(android.R.drawable.presence_invisible));
tabs.addTab(spec);
tabs.setCurrentTab(0);
spec.setIndicator("",res.getDrawable(android.R.drawable.ic_menu_rotate)) In this case icon appears.
spec.setIndicator("ddd",
res.getDrawable(android.R.drawable.presence_invisible));
Run Code Online (Sandbox Code Playgroud)
这是main.xml
<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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" > …Run Code Online (Sandbox Code Playgroud) android ×1