Lazyadapter for listview(垂直)里面,我做了什么,在水平listview&上设置lazyadapter HLV在此lazyadapter的自定义布局中声明。
class lazyadapter extends BaseAdapter {
Context context;
LayoutInflater inflater;
ArrayList<HashMap<String, String>> data;
public lazyadapter(Context context,
ArrayList<HashMap<String, String>> arraylist) {
this.context = context;
data = arraylist;
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView,
ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater
.inflate(R.layout.horizontal, parent, false);
HashMap<String, String> mapss;
mapss = new HashMap<String, String>();
String dataq = data.get(position).get("subcatname");
String catname = data.get(position).get("catname");
String image = data.get(position).get("image");
String id = data.get(position).get("id");
mapss.put("dataq", dataq);
mapss.put("image", image);
mapss.put("catname", catname);
mapss.put("id", id);
TextView uu = (TextView) itemView.findViewById(R.id.textView1);
hlvSimpleList1 = (HorizontalListView) itemView
.findViewById(R.id.hlvSimpleList1);
uu.setText(data.get(position).get("catname"));
String tttt = data.get(position).get("cc");
if (tttt.equals("1")) {
uu.setVisibility(0);
ap = new ArrayList<HashMap<String, String>>();
} else {
uu.setVisibility(8);
hlvSimpleList1.setVisibility(8);
}
ap.add(mapss);
lazyadapter4 adpp = new lazyadapter4(getApplicationContext(), ap);
adpp.notifyDataSetChanged();
hlvSimpleList1.setAdapter(adpp);
return itemView;
}
}
在Advance中感谢..请帮助我摆脱这个..
答案 0 :(得分:0)
在listview的Row.xml中(你将在适配器的getView(..)函数中膨胀)使用HorizontalScrollView作为Parent元素。