在ExpandableListView里给child的每个item添加了ImageView。如何对imageview设置监听!希望实现的效果是点击imageview弹出一个小窗口。谢谢各位大神给点指导了,小白初学最好能给点代码,不然看不懂额。
child的布局文件xml是这样的,里面有一个ImageView。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/selector_2"
android:gravity="left"
android:orientation="horizontal"
android:paddingBottom="0.0dip"
android:paddingTop="0.0dip" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="left"
android:orientation="vertical"
android:paddingBottom="0.0dip"
android:paddingTop="0.0dip" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="60dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="姓名:"
android:textColor="@color/white"
android:textSize="15dp" />
<TextView
android:id="@+id/item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="10dip"
android:textColor="@color/white"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="60dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="手机:"
android:textColor="@color/white_two"
android:textSize="15dp" />
<TextView
android:id="@+id/item_familyphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="10dip"
android:text="No data"
android:textColor="@color/white_two"
android:textSize="15dp" >
</TextView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:gravity="right"
>
<ImageView
android:id="@+id/myCursor"
android:layout_width="43.0dip"
android:layout_height="58.0dip"
android:clickable="true"
android:layout_gravity="center_vertical"
android:src="@drawable/my007" >
</ImageView>
</LinearLayout>
</LinearLayout>
ExpandableListView里是通过下面代码实现数据添加显示的。
ExpandableListView userlist = (ExpandableListView) findViewById(R.id.list02);
List<Map<String, Object>> Groups = new ArrayList<Map<String, Object>>();
Map<String, Object> groupone = new HashMap<String, Object>();
groupone.put("groupname", "技术部");
Groups.add(groupone);
Map<String, Object> grouptwo = new HashMap<String, Object>();
grouptwo.put("groupname", "销售部");
Groups.add(grouptwo);
Map<String, Object> groupthree = new HashMap<String, Object>();
groupthree.put("groupname", "人事部");
Groups.add(groupthree);
ArrayList data = DBHelper.getInstance(this).getUserList();
SimpleExpandableListAdapter simpleExpandableListAdapter = new SimpleExpandableListAdapter(
MainActivity.this, Groups, R.layout.group,
new String[] { "groupname" }, new int[] { R.id.group }, data,
R.layout.child, new String[] { "name", "familyphone" },
new int[] { R.id.item_name, R.id.item_familyphone });
userlist.setAdapter(simpleExpandableListAdapter);
child的布局文件xml是这样的,里面有一个ImageView。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/selector_2"
android:gravity="left"
android:orientation="horizontal"
android:paddingBottom="0.0dip"
android:paddingTop="0.0dip" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="left"
android:orientation="vertical"
android:paddingBottom="0.0dip"
android:paddingTop="0.0dip" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="60dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="姓名:"
android:textColor="@color/white"
android:textSize="15dp" />
<TextView
android:id="@+id/item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="10dip"
android:textColor="@color/white"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="60dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="手机:"
android:textColor="@color/white_two"
android:textSize="15dp" />
<TextView
android:id="@+id/item_familyphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="10dip"
android:text="No data"
android:textColor="@color/white_two"
android:textSize="15dp" >
</TextView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:gravity="right"
>
<ImageView
android:id="@+id/myCursor"
android:layout_width="43.0dip"
android:layout_height="58.0dip"
android:clickable="true"
android:layout_gravity="center_vertical"
android:src="@drawable/my007" >
</ImageView>
</LinearLayout>
</LinearLayout>
ExpandableListView里是通过下面代码实现数据添加显示的。
ExpandableListView userlist = (ExpandableListView) findViewById(R.id.list02);
List<Map<String, Object>> Groups = new ArrayList<Map<String, Object>>();
Map<String, Object> groupone = new HashMap<String, Object>();
groupone.put("groupname", "技术部");
Groups.add(groupone);
Map<String, Object> grouptwo = new HashMap<String, Object>();
grouptwo.put("groupname", "销售部");
Groups.add(grouptwo);
Map<String, Object> groupthree = new HashMap<String, Object>();
groupthree.put("groupname", "人事部");
Groups.add(groupthree);
ArrayList data = DBHelper.getInstance(this).getUserList();
SimpleExpandableListAdapter simpleExpandableListAdapter = new SimpleExpandableListAdapter(
MainActivity.this, Groups, R.layout.group,
new String[] { "groupname" }, new int[] { R.id.group }, data,
R.layout.child, new String[] { "name", "familyphone" },
new int[] { R.id.item_name, R.id.item_familyphone });
userlist.setAdapter(simpleExpandableListAdapter);