使用时extends Fragment
有效,但不适用于ListFragment
.
主要活动:
public class FagTabHostMain extends FragmentActivity {
FragmentTabHost mTabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fag_tab_host_main);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
mTabHost.addTab(mTabHost.newTabSpec("more").setIndicator("More"),
More.class, null);
} catch (Exception e) {
Log.e("TAG", e.toString());
}
}
}
适用于以下:
public class More extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.more, null);
return view;
}
}
但不是:
public class More extends ListFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.more, null);
return view;
}
}