-1
我想要得到一个片段以显示在Android中。当我执行代码去正确的片段时,我所看到的就是敬酒。 fragment_detail没有出现。有没有人知道这段代码有什么问题? 从调用类:Android片段不能正常工作
final FragmentManager fm = getActivity().getSupportFragmentManager();
final FragmentTransaction ft = fm.beginTransaction();
DetailFragment df = new DetailFragment();
ft.replace(R.id.pager, df, "DetailFragment").setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();
从所谓类:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
Toast.makeText(getActivity().getBaseContext(), "Blah de Blah", Toast.LENGTH_LONG).show();
return rootView;
}
的布局fragment_detail:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/fragment_content"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</FrameLayout>
</LinearLayout>
谢谢!
(R.id.pager,DDF,“ DetailFragment“)'ddf或df? – 2014-10-10 04:58:48
对不起,错字已被更正。 – user2078519 2014-10-10 16:30:31