小编Sai*_*waz的帖子

ViewPager里面的Recyclerview里面的scrollview无法正常工作

我有一个xml布局,其中包含以下视图Scrollview-> RelativeLayout-> Some Views + Tablayout + ViewPager-> Recylerview(在ViewPager的片段中).ViewPager有一些固定的高度(保持它"Wrap_Content"根本不显示它.)现在的问题是Recylerview永远不会滚动.我已经尝试了几个已经发布过的解决方案,例如在"嵌套Scrollview"中使用 Wraping viewpager 或者甚至使LinearLayout成为子项.但没有工作.

下面是我的xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/btn_startdraw"
        android:fillViewport="true"
        android:gravity="center">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:padding="@dimen/_5sdp">


            <TextView
                android:id="@+id/invites_accepted"
                style="@style/bodyStyleBlue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/committee_slots"
                android:text="@string/invites_accepted" />

               <!-- A lot of other Textfields for data display-->

                <android.support.design.widget.TabLayout
                android:id="@+id/tabs_pendingcommittee"
                style="@style/TabStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/draw_mode_val"
                app:tabMode="fixed"></android.support.design.widget.TabLayout>b


            <com.apponative.committeeapp.ui.custom.CustomViewPager
                android:id="@+id/pending_member_view"
                android:layout_width="match_parent"
                android:layout_height="@dimen/_250sdp"
                android:layout_below="@+id/tabs_pendingcommittee"
                app:layout_behavior="@string/appbar_scrolling_view_behavior" />

        </RelativeLayout>
    </android.support.v4.widget.NestedScrollView>

    <!-- Some other views on bottom-->
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

Viewpager显示的片段有以下布局xml: …

android android-viewpager android-recyclerview android-tablayout

12
推荐指数
2
解决办法
3447
查看次数

如何从行索引Swift获取indexpath

我正在加载一个数组UIcollectionview(稍后将添加其他数据).我想随机选择集合视图项:

var indexpath = Int(arc4random_uniform(UInt32(items.count)-1) 

self.collectionview.selectitem(at: **indexpath**, animated:true ,scrollPosition:UICollectionViewScrollPosition)
Run Code Online (Sandbox Code Playgroud)

这是在大胆的位置给我错误说:

无法将Int类型的值转换为预期的参数类型'IndexPath?

我可以理解这个异常,因为indexpathswift与集合数据索引(数组索引)不同.但是我找不到任何可以将项索引转换为索引路径或任何其他方法的方法.

我是iOS的新手,所以可能不擅长为这样的问题搜索正确的关键字.对于满足此要求的任何其他方法,对您来说都是一个很大的帮助.

collectionview ios swift indexpath

5
推荐指数
1
解决办法
2万
查看次数

尝试从字段'android.view.View android.support.v7.widget.RecyclerView $ ViewHolder.itemView'读取

我试图随机选择recyclerview项目延迟.我需要在片段加载后开始随机选择方法,没有任何用户交互,但得到以下错误.之后我把它放在ImageView上点击查看,但我又得到了同样的异常.这里的任何人都告诉我我在哪里犯了错误,或者还有什么可能是更好的方法来实现这个.下面是我的代码

    package com.apponative.bjja.fragments;

import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.apponative.bjja.R;
import com.apponative.bjja.adapters.AttackGridAdapter;

import java.util.Random;

public class Fragment_AttackGrid extends Fragment {

    View v;
    RecyclerView grid_attack;
    AttackGridAdapter attackGridAdapter;
    Bundle b;
    int itemCount;
    Handler randomHandler;
    Runnable randomRunnable;
    Random rand;
    int randomNum = 0;
    long emptyTime;

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

        v = inflater.inflate(R.layout.fragment_attack_grid, container, false);

        setUpViews();

        return v;
    }

    void setUpViews() {

        b = …
Run Code Online (Sandbox Code Playgroud)

android handler fragment runnable android-recyclerview

5
推荐指数
2
解决办法
9649
查看次数