当附加到android中的root时,LayoutInflater抛出stackoverflow异常

时间:2016-06-08 12:11:45

标签: java android listview exception

我正在制作一个包含三个标签的活动。每个选项卡都应该有一个列表视图。

我的片段看起来像这样

public class fragment1 extends Fragment {


public fragment1(){

}

static Context context;
static LayoutInflater inflater;

public void setDepends(Context context, LayoutInflater inflater){
    this.context = context;
    this.inflater = inflater;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    final View rootView = inflater.inflate(R.layout.guideline_fragment1, container, false);
    //some code

    return rootView;
}

但是当我尝试编写

时,列表视图不会滚动

final View rootView = inflater.inflate(R.layout.guideline_fragment1, container, true);

它抛出stackoverflow异常

这是我的主要活动xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">
</LinearLayout>

和我的片段xml

<android.support.v4.widget.SwipeRefreshLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/kid_guideline_refresh_layout"
    xmlns:android="http://schemas.android.com/apk/res/android">
        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/guideline_kids_listview"
            android:divider="@null"
            android:fillViewport="true"></ListView>
</android.support.v4.widget.SwipeRefreshLayout>

0 个答案:

没有答案