嘿伙计们我使用过Listview我想在用户点击Listview时打开另一个布局,或者你可以说像手风琴风格。
我搜索了这个,但没有准确地知道如何做到这一点?
public class CustomList extends SimpleAdapter {
private View.OnClickListener callback;
private Context mContext;
public LayoutInflater inflater=null;
public CustomList(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to , View.OnClickListener callback) {
super(context, data, resource, from, to);
mContext = context;
this.callback = callback;
inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(int position, final View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.layout, null);
vi.setOnClickListener(callback);
vi.setTag(position);
TextView lay = (TextView)vi.findViewById(R.id.arrow);
lay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LinearLayout li = (LinearLayout) view.findViewById(R.id.popup);
li.setVisibility(View.VISIBLE);
}
});
HashMap < String, Object > data = (HashMap<String, Object>) getItem(position);
TextView text = (TextView)vi.findViewById(R.id.carprice);
String name = (String) data.get(TAG_CITY);
Log.i("City", name);
text.setText(name);
// TextView text1 = (TextView)vi.findViewById(R.id.arrow);
//String name1 = (String)data.get(TAG_CITY);
//text1.setText(name1);
TextView text2 = (TextView)vi.findViewById(R.id.carname);
String name2 = (String)data.get(TAG_CITY);
text2.setText(name2);
ImageView image=(ImageView)vi.findViewById(R.id.carimg);
String image_url = (String) data.get(TAG_ID);
Log.i("City", image_url);
Picasso.with(this.mContext).load(image_url).into(image);
return vi;
}
}