当我想在我的应用程序中创建滑动选项卡 PagerView 时。但错误看到了: 的 logcat的
09-23 13:15:00.133: E/AndroidRuntime(1847): FATAL EXCEPTION: main
09-23 13:15:00.133: E/AndroidRuntime(1847): java.lang.StackOverflowError
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.widget.TextView.jumpDrawablesToCurrentState(TextView.java:4518)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
09-23 13:15:00.133: E/AndroidRuntime(1847): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5147)
我有四个FragmentTabOne,FragmentTabTwo .... FragmentTabFour
代码 FragmentTabOne.java :
public class FragmentTabOne extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragmenttabone, container);
return view;
}
}
这里我的布局文件见: 的 fragmenttabone.xml
<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="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Fragment 1" />
</RelativeLayout>
mainlayout.xml
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.PagerTabStrip
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:textColor="#000000" />
</android.support.v4.view.ViewPager>
我有这些片段和布局如何解决它。修正我的错误。
帮帮我......
答案 0 :(得分:0)
我真的不知道这可以帮到你。你可以尝试一下。
但这是我的mainlayout.xml
:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v4.view.PagerTabStripV22
android:id="@+id/pager_title_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#FF6600"
android:textColor="#fff"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:textAppearance="@style/ViewPagerStripStyle"/>
</android.support.v4.view.ViewPager>
</LinearLayout>
答案 1 :(得分:0)
例如
View view = inflater.inflate(R.layout.fragmenttabone, null);