我有一个像这样扩展Fragment的类:
public class Fragment_Coupons extends Fragment {
TabHost tabHost;
TabHost.TabSpec spec;
public Fragment_Coupons() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_coupon, container,
false);
return rootView;
}
}
这个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" >
</TabHost>
现在我想得到
tabHost = getTabHost();
这给了我一个错误。
答案 0 :(得分:0)
试试这个:
tabHost = (TabHost) findViewById(R.id.tabHost);
tabHost.setup();