我正在尝试实现动作栏选项卡,在此期间,我在实现fragment类时遇到错误。
public class fragmentImplement extends Fragment
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//setContentView(R.layout.fragment_layout);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_layout, container, false);
}
}而XML文件是
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView android:id="@+id/textView1"
android:text="Fragment A"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>好心帮助我,因为我变得非常沮丧
发布于 2014-03-20 02:02:31
请提供更多信息(错误和位置等)下次。
要使用Fragments,您还需要一个FragmentActivity。Fragment是可以在FragmentActivity中使用的可重用组件。
请使用此tutorial作为使用Fragment的起点,然后更进一步,查看this文章。
据我所知,在Android SDK中也有一个例子,它有一个带标签的ActionBar。
https://stackoverflow.com/questions/22513643
复制相似问题