Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 视讯传呼机&;ViewPagerIndicator不显示任何内容_Android_Android Layout_Android Viewpager_Viewpagerindicator - Fatal编程技术网

Android 视讯传呼机&;ViewPagerIndicator不显示任何内容

Android 视讯传呼机&;ViewPagerIndicator不显示任何内容,android,android-layout,android-viewpager,viewpagerindicator,Android,Android Layout,Android Viewpager,Viewpagerindicator,实际上,我的应用程序、我的ViewPager和ViewPagerIndicator存在问题 ()没有显示任何内容,我不明白为什么。我多次检查了所有内容(正确设置适配器,在InstanceItem中添加视图,在getCount()中返回良好的大小,…),尝试了一些事情(更改xml中的布局参数,修改MyPagerAdapter类),甚至在Google和此处查找类似的问题,但没有任何效果/问题不是我的问题 我也有一个bog,不知道它是否有链接,但是我的PagerAdapter中的InstanceIte

实际上,我的应用程序、我的ViewPager和ViewPagerIndicator存在问题 ()没有显示任何内容,我不明白为什么。我多次检查了所有内容(正确设置适配器,在InstanceItem中添加视图,在getCount()中返回良好的大小,…),尝试了一些事情(更改xml中的布局参数,修改MyPagerAdapter类),甚至在Google和此处查找类似的问题,但没有任何效果/问题不是我的问题

我也有一个bog,不知道它是否有链接,但是我的PagerAdapter中的InstanceItem方法只被调用了2次,而getCount()返回了3次

我真的不知道这是从哪里来的,如果有人有想法,我将非常高兴地接受:

一旦创建(包含ViewPager和ViewPagerIndicator的活动):

}

活动xml:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dp"
            android:text="@string/hello_world"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@color/first_color" />

        <Button
            android:id="@+id/try_vehicle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/title"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="40dp"
            android:onClick="tryingAlert"
            android:text="@string/try_vehicle" />

        <Button
            android:id="@+id/ask_informations"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/try_vehicle"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"
            android:onClick="informationsAlert"
            android:text="@string/ask_informations" />

        <Button
            android:id="@+id/remove_selection"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="removeFromSelection"
            android:layout_below="@+id/ask_informations"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"
            android:text="@string/remove_selection" />

        <HorizontalScrollView
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/remove_selection"
            android:layout_marginTop="18dp"
            android:scrollbars="none" >

            <LinearLayout
                android:id="@+id/mygallery"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
            </LinearLayout>

        </HorizontalScrollView>

        <com.viewpagerindicator.TitlePageIndicator
            android:id="@+id/titles_pager"
            android:layout_below="@id/scroll"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent" />

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/titles_pager" />

    </RelativeLayout>
</ScrollView>


(外部链接,无法发布图片抱歉!)

好的,所以最后没有任何问题,只是我做错了

如前所述,ViewPagerIndicator只是白色对白色,所以我看不到它,现在可以了

对于ViewPager,它刚好位于我的ScrollView的最末端,这意味着它没有“真正”的屏幕空间,因此
android:layout\u height=“match\u parent”
是无效的。这似乎是ViewPager的一个常见问题,我将看看我能做些什么来适应它


无论如何谢谢你的帮助,我希望这篇文章能对别人有用

面对同样的问题,并提出了解决方案。 可能有点刺痛,但它有效) 首先,在xml文件集中

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/tabs"/>
将它实现到您的片段中

public class FriendProfileTabstFragment extends AbstractFragment implements ViewPagerListener
....
pager = (ViewPager) fragmentView.findViewById(R.id.pager);
adapter = new TabsPagerAdapter(getChildFragmentManager(),user,this);
并实现方法onChange,您可以在其中设置布局高度

@Override
public void onChange(int height) {
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) pager.getLayoutParams();
    params.height = height;
    pager.setLayoutParams(params);
}
userRecordsList.measure(userRecordsList.getWidth(),userRecordsList.getHeight());
int height = userRecordsList.getMeasuredHeight();
listener.onChange(height);
在您的子片段中,您可以获得布局高度

View fragmentView = inflater.inflate(R.layout.tab_without_list_fragment, null);
userRecordsList = (LinearLayout) fragmentView.findViewById(R.id.user_records_list);
填充视图时,获取布局高度

@Override
public void onChange(int height) {
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) pager.getLayoutParams();
    params.height = height;
    pager.setLayoutParams(params);
}
userRecordsList.measure(userRecordsList.getWidth(),userRecordsList.getHeight());
int height = userRecordsList.getMeasuredHeight();
listener.onChange(height);

希望,这有帮助。如果您找到更好的解决方案,请纠正我。

我也遇到了同样的问题,我看不到选项卡指示器。因此,问题是我没有从
ViewPagerIndicator
项目中复制项目中的
style.xml
文件。希望这能对将来的用户有所帮助。

当您使用层次结构视图检查UI时,您发现了什么?@commonware这取决于您希望我看到什么…:d我发现全局上我的活动显示得很好,包括标题页指示器,但是ViewPager仍然没有显示任何内容以及它的子项(并且只有2个子项,而实例化项应该创建3个子项!)。无论如何,谢谢你对我的帮助。:)好的,我是标题指示器的工具,默认主题只提供白色,所以背景是“不可见的”。编辑:我们从这里看不到它,但是TitlePageIndicator很好地显示了3个标题。
userRecordsList.measure(userRecordsList.getWidth(),userRecordsList.getHeight());
int height = userRecordsList.getMeasuredHeight();
listener.onChange(height);