Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 碎片没有出现_Android - Fatal编程技术网

Android 碎片没有出现

Android 碎片没有出现,android,Android,我试图制作一个简单的片段示例,其中一个片段将显示文章列表,另一个片段将显示详细的文章。 这是我的主要活动课- public class ArticleFragment extends Activity{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main

我试图制作一个简单的片段示例,其中一个片段将显示文章列表,另一个片段将显示详细的文章。 这是我的主要活动课-

public class ArticleFragment extends Activity{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        }       
}// end class
这是主布局文件-

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment android:name="com.example.ArticleList"
            android:id="@+id/list"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="match_parent" />

    <fragment android:name="com.example.ArticleDetails"
            android:id="@+id/viewer"
            android:layout_weight="2"
            android:layout_width="0dp"
            android:layout_height="match_parent" />
</LinearLayout>

对于articleList和ArticleDetails片段,我还有两个XML布局文件(包含一个textview)。但该应用程序已停止工作。我错过了什么?请帮助我

检查代码中的包名

<fragment android:name="com.abc.def............./>

但是你认为其他的一切都好吗,就是代码..我的min sdk版本是api-11UPPPSSS…我的包名是com.example.articlefragment,所以我相应地更改了类名。com.example.articlefragment.MYCLASSNAME,它成功了。顺便说一句,在另一个示例中,它在片段标记中使用class=“com.example.MyclassName”来引用该类。有什么区别?THANX一点也不客气。很高兴你做到了。实际获取显示或返回视图的片段类的路径。因此,包名的路径应该是正确的。你说的~“应用程序已停止工作”是什么意思?您是否在onCreateView方法中设置断点并调试它们?
<fragment android:name="com.abc.def............./>