Это мой код для моего основного, основной xml не распознается. Я сделал чистый. также моя доступная папка не работает. Я сделал папку в моем вызове res «drawable» и добавил мой xml моих drawable и моих значков, и он не находит его.Android TAB ui help
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Drawable TestImage = getDrawable(R.drawable.ic_tab_test);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, TestActivity.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("test").setIndicator("test",
res.getDrawable(R.drawable.ic_tab_test))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, TestActivity2.class);
spec = tabHost.newTabSpec("test2").setIndicator("test2",
res.getDrawable(R.drawable.ic_tab_albums))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, TestActivity3.class);
spec = tabHost.newTabSpec("test3").setIndicator("test3",
res.getDrawable(R.drawable.ic_tab_songs))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(2);
}
}
Вот мой главный XML
<?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"
android:padding="5dp" />
</LinearLayout>
</TabHost>
Я не могу показаться, чтобы увидеть, что ошибка вызвана из? Помоги мне, пожалуйста. Я просто изучаю это
Entreco правильно объяснил. Попробуйте очистить проект до его запуска. – Vinoth