【发布时间】:2011-09-10 14:16:26
【问题描述】:
我正在尝试向我的主要活动添加一个片段,这是 main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<fragment android:name="wj.tweetTab.Titles"
android:layout_width="300dp"
android:layout_height="match_parent" />
</LinearLayout>
wj.tweetTab.Titles 类是 Fragment 类的扩展,它仅覆盖 onCreateView 以扩充其 xml 布局资源:
package wj.tweetTab;
import android.app.Fragment;
public class Titles extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(wj.tweetTab.R.layout.titles, container);
}
}
这是标题片段的titles.xml 布局,它只是一个带有文本视图的线性布局:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="16sp"
android:text="TEXTTEXTTEXT!!!">
</TextView>
</LinearLayout>
当我尝试在我的物理 android 选项卡上运行应用程序时,我收到 Source not found 错误。如果我从应用程序运行的main.xml 文件中删除片段 xml。
任何想法为什么会发生这种情况?
【问题讨论】: