Can't use viewpager tabs in android project

What I am doing: I am trying to use the pager view tab indicator.

What I've done:

  • I linked the library
  • I have reflected styles.xml in all value folders
  • Copied all the necessary drawings from the sample

manifest:

<activity
    android:name="com.windhyaworks.activities.ActMain"
    android:configChanges="orientation|keyboardHidden"
    android:screenOrientation="portrait"
    android:theme="@style/StyledIndicators" />

      

styles.xml

<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

    <style name="mydialogstyle" parent="android:style/Theme.Dialog">
        <item name="android:windowBackground">@android:color/white</item>
        <item name="android:windowNoTitle">false</item>
    </style>

    <style name="StyledIndicators" parent="AppTheme">
        <item name="vpiTabPageIndicatorStyle">@style/CustomTabPageIndicator</item>
    </style>

    <style name="CustomTabPageIndicator" parent="Widget.TabPageIndicator">
        <item name="android:background">@drawable/custom_tab_indicator</item>
        <item name="android:textAppearance">@style/CustomTabPageIndicator.Text</item>
        <item name="android:textColor">#FF555555</item>
        <item name="android:textSize">16sp</item>
        <item name="android:divider">@drawable/custom_tab_indicator_divider</item>
        <item name="android:dividerPadding">10dp</item>
        <item name="android:showDividers">middle</item>
        <item name="android:paddingLeft">8dp</item>
        <item name="android:paddingRight">8dp</item>
        <item name="android:fadingEdge">horizontal</item>
        <item name="android:fadingEdgeLength">8dp</item>
    </style>

    <style name="CustomTabPageIndicator.Text" parent="android:TextAppearance.Medium">
        <item name="android:typeface">monospace</item>
    </style>

</resources>

      

In XML graphics, I can't see the layout and I see these warnings below.

Missing styles. Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.

Failed to find style 'vpiTabPageIndicatorStyle' in current theme
Exception raised during rendering: ViewPager has not been bound.
Exception details are logged in Window > Show View > Error Log

java.lang.IllegalStateException: ViewPager has not been bound.
    at com.viewpagerindicator.TabPageIndicator.setCurrentItem(TabPageIndicator.java:240)
    at com.viewpagerindicator.TabPageIndicator.onMeasure(TabPageIndicator.java:116)
    at android.view.View.measure(View.java:17430)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
    at android.view.View.measure(View.java:17430)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
    at android.view.View.measure(View.java:17430)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
    at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:447)
    at android.view.View.measure(View.java:17430)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
    at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1083)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:615)
    at android.view.View.measure(View.java:17430)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
    at android.view.View.measure(View.java:17430)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
    at android.view.View.measure(View.java:17430)

      

-1


source to share


1 answer


idk is Eclipse or AndroidStudio or whatever.

I work in Android Studio and sometimes I don't have autocomplete options (for support library). Instead, I:



  • Delete this layout file
  • Create a new one (use the same name if you've already used it in your code) and as a Control Type ViewPager
  • It should make the starting ViewPager code, if not, in the Design tab it will report a problem (similar to the ones you mentioned) and a link to v4-ViewPager. Click on it and you should have a start code.
0


source







All Articles