Java 膨胀片段类时特定的二进制XML文件行#133异常

Java 膨胀片段类时特定的二进制XML文件行#133异常,java,android,xml,android-fragments,Java,Android,Xml,Android Fragments,我已经看到过类似的错误,但没有一个对我有帮助。我有一个活动,我可以把图片从画廊的按钮点击。所以,当我选择picture并尝试返回活动时,我得到了这个错误 11-14 15:00:26.884: W/dalvikvm(19944): threadid=1: thread exiting with uncaught exception (group=0x40c4a1f8) 11-14 15:00:26.904: E/AndroidRuntime(19944): FA

我已经看到过类似的错误,但没有一个对我有帮助。我有一个活动,我可以把图片从画廊的按钮点击。所以,当我选择picture并尝试返回活动时,我得到了这个错误

    11-14 15:00:26.884: W/dalvikvm(19944): threadid=1: thread exiting with uncaught          exception (group=0x40c4a1f8)
    11-14 15:00:26.904: E/AndroidRuntime(19944): FATAL EXCEPTION: main
    11-14 15:00:26.904: E/AndroidRuntime(19944): java.lang.RuntimeException: Unable to start  activity ComponentInfo{rs.telegraf.io/rs.telegraf.io.MainActivitySendNews}:   android.view.InflateException: Binary XML file line #133: Error inflating class fragment
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.os.Handler.dispatchMessage(Handler.java:99)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.os.Looper.loop(Looper.java:137)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.app.ActivityThread.main(ActivityThread.java:4424)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at java.lang.reflect.Method.invokeNative(Native Method)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at java.lang.reflect.Method.invoke(Method.java:511)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at dalvik.system.NativeStart.main(Native Method)
    11-14 15:00:26.904: E/AndroidRuntime(19944): Caused by: android.view.InflateException: Binary XML file line #133: Error inflating class fragment
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at     android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:119)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at rs.telegraf.io.MainActivitySendNews.onCreate(MainActivitySendNews.java:145)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.app.Activity.performCreate(Activity.java:4465)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    ... 11 more
    11-14 15:00:26.904: E/AndroidRuntime(19944): Caused by: java.lang.IllegalStateException: Fragment rs.telegraf.io.Fragment did not create a view.
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:303)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
    11-14 15:00:26.904: E/AndroidRuntime(19944):    ... 24 more
我想也许我应该早点给我的碎片充气或者类似的事情。还有一个有趣的事实,它只是偶尔发生,有时我会添加图片并正常返回MainActivitySendNews活动。这是发生异常的xml文件和生成此片段的MainActivitySendNews类:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#EEEEEE" >

<ScrollView
    android:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#EEEEEE" >

    <RelativeLayout
        android:id="@+id/rl"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#EEEEEE"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin" >

        <TextView
            android:id="@+id/naslov_opis"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginTop="0dp"
            android:gravity="center_horizontal"
            android:paddingTop="5dp"
            android:text="@string/opis" />

        <RelativeLayout
            android:id="@+id/kategorija_opis"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/naslov_opis"
            android:layout_marginTop="10dp" >

            <TextView
                android:id="@+id/izbor_kat_naslov"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:text="@string/dodaj_kategorija" />

            <View
                android:id="@+id/prva_linija_naslov"
                android:layout_width="wrap_content"
                android:layout_height="1dp"
                android:layout_centerVertical="true"
                android:layout_toRightOf="@id/izbor_kat_naslov"
                android:background="#D5D5D5" />

            <View
                android:id="@+id/druga_linija_naslov"
                android:layout_width="wrap_content"
                android:layout_height="1dp"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@id/izbor_kat_naslov"
                android:background="#D5D5D5" />
        </RelativeLayout>

        <Spinner
            android:id="@+id/izbor"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/kategorija_opis"
            android:layout_marginBottom="50dp"
            android:layout_marginTop="20dp"
            android:gravity="center" />

        <View
            android:id="@+id/srednja"
            android:layout_width="1dp"
            android:layout_height="50dp"
            android:layout_centerInParent="true"
            android:layout_marginTop="8dp"
            android:background="#EEEEEE" />

        <RelativeLayout
            android:id="@+id/relative_odabir"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/izbor"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp" >

            <TextView
                android:id="@+id/dodaj"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:text="@string/dodaj" />

            <View
                android:id="@+id/prva_linija"
                android:layout_width="wrap_content"
                android:layout_height="1dp"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@id/dodaj"
                android:background="#D5D5D5" />

            <View
                android:id="@+id/duga_linija"
                android:layout_width="wrap_content"
                android:layout_height="1dp"
                android:layout_centerVertical="true"
                android:layout_toRightOf="@id/dodaj"
                android:background="#D5D5D5" />
        </RelativeLayout>

        <rs.telegraf.io.ExpandableHeightGridView
            android:id="@+id/gridview"
            android:layout_width="@dimen/grid_width"
            android:layout_height="wrap_content"
            android:layout_below="@id/relative_odabir"
            android:layout_centerHorizontal="true"
            android:background="#EEEEEE"
            android:gravity="center"
            android:horizontalSpacing="5dp"
            android:numColumns="3"
            android:padding="0dp"
            android:verticalSpacing="5dp" >
        </rs.telegraf.io.ExpandableHeightGridView>

        <fragment
            android:id="@+id/fragment"
            android:name="rs.telegraf.io.Fragment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/gridview"
            android:layout_marginBottom="20dp"
            android:layout_marginTop="10dp"
            class="rs.telegraf.io.Fragment" >
        </fragment>

        <Button
            android:id="@+id/odustani"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_alignRight="@id/srednja"
            android:layout_below="@id/fragment"
            android:layout_marginRight="@dimen/razma_dugmici"
            android:background="@drawable/odustani_selector" />

        <Button
            android:id="@+id/posalji"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@id/srednja"
            android:layout_below="@id/fragment"
            android:layout_marginLeft="@dimen/razma_dugmici"
            android:background="@drawable/posalji_selector" />
    </RelativeLayout>
</ScrollView>

这是MainActivitySendNews的OnCreate方法:

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.send_news_main);
    pictureAlertWithContent.add(getResources().getDrawable(
            R.drawable.item_click_send_new_camera));
    pictureAlertWithContent.add(getResources().getDrawable(
            R.drawable.item_click_send_new_galery));
    pictureAlertWithContent.add(getResources().getDrawable(
            R.drawable.item_click_send_new_delete));

    pictureAlertEmpty.add(getResources().getDrawable(
            R.drawable.item_click_send_new_camera));
    pictureAlertEmpty.add(getResources().getDrawable(
            R.drawable.item_click_send_new_galery));
    pictureAlertEmpty.add(getResources().getDrawable(
            R.drawable.item_click_send_new_delete));

    ScrollView src = (ScrollView) findViewById(R.id.scroll);
    src.setClickable(false);

    cansel = (Button) findViewById(R.id.odustani);

    cansel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });
    // kamera=(ImageButton)findViewById(R.id.kamera);
    // galerija=(ImageButton)findViewById(R.id.galerija);
    posalji = (Button) findViewById(R.id.posalji);
    posalji.setVisibility(View.INVISIBLE);
    // cansel.setVisibility(View.INVISIBLE);

    // intent_for_galery = new Intent(this, ImageGridActivity.class);
    imageItems = getData();

    pictures.put("0", "empty");
    pictures.put("1", "empty");
    pictures.put("2", "empty");
    pictures.put("3", "empty");
    pictures.put("4", "empty");
    pictures.put("5", "empty");
    gridView = (ExpandableHeightGridView) findViewById(R.id.gridview);
    customGridAdapter = new GridViewAdapter(this, R.layout.row_grid,
            imageItems);
    gridView.setAdapter(customGridAdapter);
    gridView.setExpanded(true);

    gridView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v,
                int position, long id) {

            if ((pictures.get(String.valueOf(position)).equals("empty"))) {
                dialog_choise = onCreateDialogSingleChoice(position);

                dialog_choise.show();
            } else {
                dialog_choise = onCreateDialogSingleChoiceWithContent(position);

                dialog_choise.show();

            }
        }
    });
    // lista za izbor vrste oglasa

    spinner = (Spinner) findViewById(R.id.izbor);
    fragmenti = new ArrayList<rs.telegraf.io.Fragment>();
    adp = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, list_za_spinner);
    dialog = new ProgressDialog(MainActivitySendNews.this);
    dialog.setCanceledOnTouchOutside(false);
    new load().execute("");

    int i = getResources().getConfiguration().orientation;
    if (i == Configuration.ORIENTATION_LANDSCAPE)
        margine(i);
    posalji.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            boolean for_send = true;

            if (number_of_pictures != 6) {
                userDetJson = new JSONObject();
                userDetJsonArray = new JSONArray();
                List<EditText> editboxesEditTexts = fragmenti.get(
                        position_spiner).getEditboxes();
                List<String> parameters = fragmenti.get(position_spiner)
                        .getData().getParametri();
                try {
                    for (int i = 0; i < editboxesEditTexts.size(); i++) {

                        String tmp = String.valueOf(parameters.get(i)
                                .charAt(0));

                        if (tmp.equals("*"))

                        {
                            if ((editboxesEditTexts.get(i).getText()
                                    .toString()).equals("")) {
                                Toast.makeText(
                                        getApplicationContext(),
                                        getString(R.string.please)
                                                + " "
                                                + editboxesEditTexts.get(i)
                                                        .getHint(),
                                        Toast.LENGTH_LONG).show();
                                for_send = false;
                                break;
                            }

                            else {

                                userDetJson.put(parameters.get(i),
                                        editboxesEditTexts.get(i).getText());
                            }
                        } else {

                            userDetJson.put(parameters.get(i),
                                    editboxesEditTexts.get(i).getText());

                        }

                    }

                } catch (Exception e) {
                }

            } else {

                for_send = false;
                Toast.makeText(getApplicationContext(),
                        R.string.error_number_picture, Toast.LENGTH_LONG)
                        .show();
            }
            if (!pick_category) {
                Toast.makeText(getApplicationContext(),
                        "Morate izabrati kategoriju", Toast.LENGTH_LONG)
                        .show();
            }
            if (for_send && pick_category) {
                new SendData().execute();
                finish();
            }

        }
    });

}
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.send_news_main);
pictureAlertWithContent.add(getResources().getDrawable(
R.可绘制。项目(单击“发送”按钮(新建摄像头));
pictureAlertWithContent.add(getResources().getDrawable(
R.可绘制。项目(单击发送新项目);
pictureAlertWithContent.add(getResources().getDrawable(
R.可绘制。项目(单击“发送”\u“新建”\u“删除”);
pictureAlertEmpty.add(getResources().getDrawable(
R.可绘制。项目(单击“发送”按钮(新建摄像头));
pictureAlertEmpty.add(getResources().getDrawable(
R.可绘制。项目(单击发送新项目);
pictureAlertEmpty.add(getResources().getDrawable(
R.可绘制。项目(单击“发送”\u“新建”\u“删除”);
ScrollView src=(ScrollView)findViewById(R.id.scroll);
src.setClickable(假);
cansel=(按钮)findViewById(R.id.odustani);
cansel.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
//TODO自动生成的方法存根
完成();
}
});
//kamera=(ImageButton)findViewById(R.id.kamera);
//galerija=(图像按钮)findViewById(R.id.galerija);
posalji=(按钮)findViewById(R.id.posalji);
setVisibility(View.INVISIBLE);
//cansel.setVisibility(视图不可见);
//intent\u for\u galery=新的intent(这是ImageGridActivity.class);
imageItems=getData();
图片。放置(“0”,“空”);
图片。放置(“1”,“空”);
图片。放置(“2”,“空”);
图片。放置(“3”,“空”);
图片。放置(“4”,“空”);
图片。放置(“5”,“空”);
gridView=(ExpandableHeightGridView)findViewById(R.id.gridView);
customGridAdapter=新GridViewAdapter(此,R.layout.row\u网格,
图像项目);
setAdapter(customGridAdapter);
setExpanded(true);
setOnItemClickListener(新的OnItemClickListener(){
public void onItemClick(AdapterView父视图、视图v、,
内部位置,长id){
if((pictures.get(String.valueOf(position)).equals(“empty”)){
dialog\u choise=onCreateDialogSingleChoice(位置);
dialog_choise.show();
}否则{
dialog_choise=onCreateDialogSingleChoiceWithContent(位置);
dialog_choise.show();
}
}
});
//利斯塔·扎·伊兹博尔·沃斯特·奥格拉萨酒店
微调器=(微调器)findViewById(R.id.izbor);
fragmenti=新的ArrayList();
adp=新阵列适配器(此,
android.R.layout.simple_list_item_1,list_za_微调器);
dialog=新建进度对话框(MainActivitySendNews.this);
对话框。setCanceledOnTouchOutside(false);
新加载()。执行(“”);
int i=getResources().getConfiguration().orientation;
if(i==Configuration.ORIENTATION\u横向)
玛金(一);
setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
//TODO自动生成的方法存根
布尔值表示_send=true;
if(图片数量!=6){
userDetJson=新的JSONObject();
userDetJsonArray=新JSONArray();
List editboxeseditxts=fragmenti.get(
位置.getEditBox();
列表参数=fragmenti.get(位置\u spiner)
.getData().GetParameteri();
试一试{
对于(int i=0;i