0
我在我的Android應用2層回收的意見,如下圖所示:Android的嵌套循環器瀏覽
一個實際上是其他的父母。孩子是真正意義上的廣場應該是圖像的區域。現在,我在設置包含圖像的孩子的適配器時遇到問題。 這就是我想要到目前爲止「父」適配器上:
@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"
}
]
}