首页 > 代码库 > Listview 点击获取view

Listview 点击获取view

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);
}

}
}
});