listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
ViewGroup vg = (ViewGroup) listview;
int count = vg.getChildCount();
Log.v("position",String.valueOf(position));
for (int i = 0; i < count; i++) {
View v1 = vg.getChildAt(i);
LinearLayout llyout = (LinearLayout)v1.findViewById(R.id.linearLayout2);
if(i==position)
{
llyout.setVisibility(View.VISIBLE);
GridView gvson = (GridView)v1.findViewById(R.id.gdv_son);
}else{
llyout.setVisibility(View.GONE);
}
}
}
});
Listview 点击获取view,布布扣,bubuko.com
时间: 2024-10-06 01:18:13