一个实际上是另一个的父母。孩子是正方形的区域,在真正意义上应该是图像。现在,我在设置保存图像的子项的适配器时遇到问题。 这是我到目前为止在“父”适配器上尝试的内容:
@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数据。我从API获得的整个JSON看起来像:
{
"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 :(得分:0)
查看您的问题我认为您需要实施Expandable RecyclerView 使用:
compile 'com.bignerdranch.android:expandablerecyclerview:2.0.3'
可扩展的RecyclerView顾名思义,可以扩展视图,里面有自己的子视图 检查外部库