正在逐渐错误inflating fragment error while running calling an Activity which having fragments.
二进制XML文件行#9:错误充气类片段
检查表是包含listview and Description fragments.
及其XML代码的活动:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_height="match_parent">
<fragment class="com.uday.honeytest.CheckList$listview"
android:id="@+id/titles" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent" />
<fragment class="com.uday.honeytest.CheckList$Description"
android:id="@+id/details" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent"
android:background="?android:attr/detailsElementBackground" />
</LinearLayout>
核对表类是:
public class CheckList extends Activity {
static int position=0;
static CheckList check;
public void onCreate(Bundle saved){
super.onCreate(saved);
setContentView(R.layout.checklist);
}
public static class listview extends ListFragment {
View mConverView;
String[] items;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
xxxxxx..
return mConverView;
}
}
同样我有这个下面的描述片段。
但正在逐渐的setContentView线
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.uday.honeytest/com.uday.honeytest.CheckList}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
错误。
和我描述段类:编辑:
public static class Description extends Fragment {
View mConverView;
String details[];
public static Description getInstance() {
Description desc=new Description();
return desc;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
TextView textview=new TextView(getActivity());
textview.setLayoutParams(new LayoutParams(MarginLayoutParams.WRAP_CONTENT, MarginLayoutParams.WRAP_CONTENT));
return textview;
}
}
我究竟做错了什么?
感谢
你应该真的发布你的描述类代码。 – RoflcoptrException
检查我的描述片段类编辑:这是在CheckList活动只。 – Udaykiran
我从这里试过这个例子:http://www.vogella.com/articles/Android/article.html#fragments 和我有2个问题: - 我需要使用'android.support.v4.app '而不是'android.app.Fragment'因为我在API级别8(Android在Android 3.0(API级别11)中引入了片段) - android:layout_marginTop =“android:attr/actionBarSize”与API级别8不兼容 - 请参阅http:// stackoverflow。com/questions/7760817/how-to-get-androidattr-actionbarsize-with-compatibility-library – Paul