shaki_phd
چهارشنبه 06 فروردین 1393, 15:27 عصر
با سلام
من در ایجاد تب در برنامه مشکل دارم و با خطا روبرو می شم
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;
public class TabActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
Intent i = new Intent(this,Simple.class);
TabHost mTabHst = getTabHost();
mTabHst.addTab(mTabHst.newTabSpec("tab_test1").setIndicator("One",res.getDrawable(R.drawable.one)).setContent(i));
mTabHst.addTab(mTabHst.newTabSpec("tab_test2").setIndicator("Two",res.getDrawable(R.drawable.two)).setContent(i));
mTabHst.addTab(mTabHst.newTabSpec("tab_test3").setIndicator("Three",res.getDrawable(R.drawable.three)).setContent(i)) ;
mTabHst.setCurrentTab(0);
}
}
<?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:paddingTop="5dip">
<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>
اما متاسفانه با خطای Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' روبرو میشم و تب نمایش داده نمیشود
سپاس
من در ایجاد تب در برنامه مشکل دارم و با خطا روبرو می شم
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;
public class TabActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
Intent i = new Intent(this,Simple.class);
TabHost mTabHst = getTabHost();
mTabHst.addTab(mTabHst.newTabSpec("tab_test1").setIndicator("One",res.getDrawable(R.drawable.one)).setContent(i));
mTabHst.addTab(mTabHst.newTabSpec("tab_test2").setIndicator("Two",res.getDrawable(R.drawable.two)).setContent(i));
mTabHst.addTab(mTabHst.newTabSpec("tab_test3").setIndicator("Three",res.getDrawable(R.drawable.three)).setContent(i)) ;
mTabHst.setCurrentTab(0);
}
}
<?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:paddingTop="5dip">
<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>
اما متاسفانه با خطای Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' روبرو میشم و تب نمایش داده نمیشود
سپاس