Java Android-Android.view.InflateException:膨胀类片段时出现二进制XML文件错误

Java Android-Android.view.InflateException:膨胀类片段时出现二进制XML文件错误,java,android,xml,android-layout,android-fragments,Java,Android,Xml,Android Layout,Android Fragments,我正试图在我的主活动(ReportFormActivity)中放置一个片段,其中包含一个自定义listview。我想将一个包含5个按钮和一个微调器的自定义布局充气到其中。我不断收到上述错误。以下是我的完整代码 public class ReportFormActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate

我正试图在我的主活动(ReportFormActivity)中放置一个片段,其中包含一个自定义listview。我想将一个包含5个按钮和一个微调器的自定义布局充气到其中。我不断收到上述错误。以下是我的完整代码

public class ReportFormActivity extends FragmentActivity  {




@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_report_form);

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); //forces the activity to be displayed in landscape mode.

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
}

public class ButtonRowFragment extends Fragment implements android.view.View.OnClickListener{

Button optionA;
Button optionB;
Button optionC;
Button optionD;
Button optionN;
Spinner interactiveTaskSpinner;
ListView list;
ButtonAdapter adapter;
public ButtonRowFragment CustomListView = null;
public ArrayList<ListModel> CustomListViewValuesArr = new ArrayList<ListModel>();

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    //watch out here
    View view= inflater.inflate(R.layout.listview, container, false);

    CustomListView = this;
    setListData();
    Resources res = getResources();
    list = (ListView)getView().findViewById(R.id.list); 
    adapter = new ButtonAdapter(CustomListView, CustomListViewValuesArr,res);
    list.setAdapter(adapter);

     optionA=(Button)view.findViewById(R.id.button1);
     optionB=(Button)view.findViewById(R.id.button2);
     optionC=(Button)view.findViewById(R.id.button3);
     optionD=(Button)view.findViewById(R.id.button4);
     optionN=(Button)view.findViewById(R.id.button5);



           optionA.setOnClickListener(this);
           optionB.setOnClickListener(this);
           optionC.setOnClickListener(this);
           optionD.setOnClickListener(this);
           optionN.setOnClickListener(this);

           interactiveTaskSpinner = (Spinner)view. findViewById(R.id.interactive_task_spinner);
    return view;
}

public void setListData() {

    for (int i = 0; i < 11; i++) {

        final ListModel sched = new ListModel();

        /******* Firstly take data in model object ******/
        sched.setCompanyName("Button " + i);
        sched.setImage("Spinner" + i);


        sched.setUrl("http:\\www." + i + ".com");

        /******** Take Model Object in ArrayList **********/
        CustomListViewValuesArr.add(sched);
    }
}       
    public void onItemClick(int mPosition)
    {
        ListModel tempValues = ( ListModel ) CustomListViewValuesArr.get(mPosition);


       // SHOW ALERT                  

       // Toast.makeText(CustomListView, ""+tempValues.getCompanyName() +" Image:"+tempValues.getImage() +" Url:"+tempValues.getUrl(), Toast.LENGTH_LONG).show();
    }

    @Override

        public void onClick(View view) {
            // TODO Auto-generated method stub
             switch(view.getId()){
             case R.id.button1:
                  //DO something
                 optionA.setBackgroundColor(getResources().getColor(R.color.green));

                 optionC.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionD.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionN.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionB.setBackgroundColor(getResources().getColor(R.color.purple));

             break;
             case R.id.button2:
                  //DO something
                 optionA.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionC.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionD.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionN.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionB.setBackgroundColor(getResources().getColor(R.color.green));
             break;
             case R.id.button3:
                  //DO something
                 optionA.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionD.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionN.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionB.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionC.setBackgroundColor(getResources().getColor(R.color.green));
             break;
             case R.id.button4:
                 //DO something
                 optionA.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionC.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionN.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionB.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionD.setBackgroundColor(getResources().getColor(R.color.green));
            break;
             case R.id.button5:
                 //DO something
                 optionA.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionC.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionD.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionB.setBackgroundColor(getResources().getColor(R.color.purple));
                 optionN.setBackgroundColor(getResources().getColor(R.color.green));
            break;
         }
        }
    }
public类按钮rowfragment扩展片段实现android.view.view.OnClickListener{
按钮选项a;
按钮选项B;
按钮选项C;
按钮选项D;
按钮选项n;
Spinner interactiveTaskSpinner;
列表视图列表;
按钮适配器;
public ButtonRowFragment CustomListView=null;
public ArrayList CustomListViewValuesArrayList=新ArrayList();
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
//小心这里
视图=充气机。充气(R.layout.listview,container,false);
CustomListView=这个;
setListData();
Resources res=getResources();
list=(ListView)getView().findViewById(R.id.list);
适配器=新按钮适配器(CustomListView、CustomListViewValuesR、res);
list.setAdapter(适配器);
optionA=(按钮)view.findViewById(R.id.button1);
optionB=(按钮)view.findViewById(R.id.button2);
optionC=(按钮)view.findViewById(R.id.button3);
optionD=(按钮)view.findViewById(R.id.button4);
optionN=(按钮)view.findViewById(R.id.button5);
optionA.setOnClickListener(此选项);
optionB.setOnClickListener(此选项);
optionC.setOnClickListener(此选项);
optionD.setOnClickListener(此);
optionN.setOnClickListener(此选项);
interactiveTaskSpinner=(Spinner)view.findViewById(R.id.interactive\u task\u Spinner);
返回视图;
}
public void setListData(){
对于(int i=0;i<11;i++){
最终ListModel sched=新ListModel();
/*******首先在模型对象中获取数据******/
附表setCompanyName(“按钮”+i);
附表setImage(“微调器”+i);
sched.setUrl(“http:\\www.“+i+”.com”);
/********在ArrayList中获取模型对象**********/
CustomListViewValuesArr.add(附表);
}
}       
公共空间链接(集成)
{
ListModel tempValues=(ListModel)CustomListViewValuesArr.get(mPosition);
//显示警惕
//Toast.makeText(CustomListView,“+tempValues.getCompanyName()+”图像:“+tempValues.getImage()+”Url:“+tempValues.getUrl(),Toast.LENGTH_LONG).show();
}
@凌驾
公共void onClick(视图){
//TODO自动生成的方法存根
开关(view.getId()){
案例R.id.button1:
//做点什么
optionA.setBackgroundColor(getResources().getColor(R.color.green));
optionC.setBackgroundColor(getResources().getColor(R.color.purple));
setBackgroundColor(getResources().getColor(R.color.purple));
optionN.setBackgroundColor(getResources().getColor(R.color.purple));
optionB.setBackgroundColor(getResources().getColor(R.color.purple));
打破
案例R.id.按钮2:
//做点什么
optionA.setBackgroundColor(getResources().getColor(R.color.purple));
optionC.setBackgroundColor(getResources().getColor(R.color.purple));
setBackgroundColor(getResources().getColor(R.color.purple));
optionN.setBackgroundColor(getResources().getColor(R.color.purple));
optionB.setBackgroundColor(getResources().getColor(R.color.green));
打破
外壳R.id.按钮3:
//做点什么
optionA.setBackgroundColor(getResources().getColor(R.color.purple));
setBackgroundColor(getResources().getColor(R.color.purple));
optionN.setBackgroundColor(getResources().getColor(R.color.purple));
optionB.setBackgroundColor(getResources().getColor(R.color.purple));
optionC.setBackgroundColor(getResources().getColor(R.color.green));
打破
外壳R.id.按钮4:
//做点什么
optionA.setBackgroundColor(getResources().getColor(R.color.purple));
optionC.setBackgroundColor(getResources().getColor(R.color.purple));
optionN.setBackgroundColor(getResources().getColor(R.color.purple));
optionB.setBackgroundColor(getResources().getColor(R.color.purple));
setBackgroundColor(getResources().getColor(R.color.green));
打破
外壳R.id.按钮5:
//做点什么
optionA.setBackgroundColor(getResources().getColor(R.color.purple));
optionC.setBackgroundColor(getResources().getColor(R.color.purple));
setBackgroundColor(getResources().getColor(R.color.purple));
optionB.setBackgroundColor(getResources().getColor(R.color.purple));
optionN.setBackgroundColor(getResources().getColor(R.color.green));
打破
}
}
}
这是ReportFormActivity的xml布局

下面是listview的布局(意味着在listview中膨胀)



发布listview布局列表来自何处?>列表(布局)将在片段中膨胀的listview中膨胀。
<?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="wrap_content"
android:padding="10dp"
android:orientation="horizontal" >



    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Topic Presentation"
        android:textSize="19px" />

    <Button
        android:id="@+id/button1"
        android:layout_width="30dp"
        android:layout_height="30dip"
        android:background="@color/Purple"
        android:text="A"
        android:layout_marginLeft="30dp"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:textStyle="bold" />

    <Button
        android:id="@+id/button2"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_marginLeft="20dp"
        android:background="@color/Purple"
        android:text="B"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:textStyle="bold" />

    <Button
        android:id="@+id/button3"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_marginLeft="20dp"
        android:background="@color/Purple"
        android:text="C"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:textStyle="bold" />

    <Button
        android:id="@+id/button4"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_marginLeft="20dp"
        android:background="@color/Purple"
        android:text="D"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:textStyle="bold" />

    <Button
        android:id="@+id/button5"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_marginLeft="20dp"
        android:background="@color/Purple"
        android:text="NTP"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:textStyle="bold" />

    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="wrap_content"
        android:layout_height="31dp" />

</LinearLayout>