2016-03-03 131 views
0

我在我的Android应用2层回收的意见,如下图所示:enter image description hereAndroid的嵌套循环器浏览

一个实际上是其他的父母。孩子是真正意义上的广场应该是图像的区域。现在,我在设置包含图像的孩子的适配器时遇到问题。 这就是我想要到目前为止“父”适配器上:

@Override 
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 
     View v = LayoutInflater.from(parent.getContext()) 
       .inflate(R.layout.feed_list_row, parent, false); 

     // Set the view to the ViewHolder 
     MyViewHolder holder = new MyViewHolder(v); 

     holder.mHorizontalListView.setHasFixedSize(false); 
     holder.mHorizontalListView.setHorizontalScrollBarEnabled(true); 

     // use a grid layout manager 
     GridLayoutManager mLayoutManager = new GridLayoutManager(parent.getContext(), 3); 
     holder.mHorizontalListView.setLayoutManager(mLayoutManager); 

     return holder; 
    } 

    @Override 
    public void onBindViewHolder(MyViewHolder holder, int position) { 
     FeedItem feedItem = feedItems.get(position); 
     holder.name.setText(feedItem.getName()); 
     holder.timestamp.setText(feedItem.getTimeStamp()); 
     holder.profilePic.setImageUrl(feedItem.getProfilePic(), imageLoader); 

     List<FeedPhoto> feedItemPhotos = new ArrayList<>(); 

     feedPhotosAdapter = new FeedPhotosAdapter(mContext, feedItemPhotos); 
     holder.mHorizontalListView.setAdapter(feedPhotosAdapter); 
     feedPhotosAdapter.notifyDataSetChanged(); 
    } 

我被困在获得JSON数据为孩子适配器。整个JSON我从我的API获取的样子:

{ 
    "feed": [ 
    { 
     "username": "denny", 
     "profile_pic": "http://api.androidhive.info/feed/img/lincoln.jpg", 
     "name": "Denny Wayne", 
     "timestamp": "1403375851930", 
     "images": [ 
     { 
      "url": "http://scontent-a-fra.cdninstagram.com/hphotos-xpf1/t51.2885-15/s306x306/e15/10665483_429615813855717_1490926670_n.jpg" 
     }, 
     { 
      "url": "http://scontent-b-fra.cdninstagram.com/hphotos-xaf1/t51.2885-15/s306x306/e15/10891026_694434897342602_1094773634_n.jpg" 
     }, 
     { 
      "url": "http://scontent-a-fra.cdninstagram.com/hphotos-xaf1/t51.2885-15/s306x306/e15/10894920_1382218332084671_10354293_n.jpg" 
     } 
     ], 
     "id": "1" 
    }, 
    { 
     "username": "denny", 
     "profile_pic": "http://api.androidhive.info/feed/img/discovery.jpg", 
     "name": "Denny Wainaina", 
     "timestamp": "1403375851930", 
     "images": [ 
     { 
      "url": "http://scontent-b-fra.cdninstagram.com/hphotos-xfa1/t51.2885-15/s306x306/e15/10895429_768163716566132_692639371_n.jpg" 
     }, 
     { 
      "url": "http://scontent-b-fra.cdninstagram.com/hphotos-xaf1/t51.2885-15/s306x306/e15/10899087_405295322969722_20422376_n.jpg" 
     }, 
     { 
      "url": "http://scontent-a-fra.cdninstagram.com/hphotos-xaf1/t51.2885-15/s306x306/e15/10899123_922231267802027_1123900984_n.jpg" 
     } 
     ], 
     "id": "2" 
    } 
    ] 
} 

回答

0

看你的问题,我认为你需要实现可扩展RecyclerView 使用:顾名思义的

compile 'com.bignerdranch.android:expandablerecyclerview:2.0.3' 

扩展RecyclerView视图可以扩展它具有内部 检查自己的子视图这里的外部库

Expandable RecyclerView on Github