2013年8月25日星期日

Android ExpandableListView child in each item to add ImageView. Howto set imageview listen!

In ExpandableListView child in each item to add ImageView. How to set imageview listen! Hope to achieve the effect of a small window pops up click on imageview. Thank you for the great God guided to the point, white point code beginner best to give, or do not understand the amount.

child xml layout file is like this, which has an ImageView.

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">

android: layout_width = "wrap_content"
android: layout_height = "fill_parent"
android: gravity = "left"
android: orientation = "vertical"
android: paddingBottom = "0.0dip"
android: paddingTop = "0.0dip">

android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: gravity = "center_vertical"
android: orientation = "horizontal"
android: paddingLeft = "60dip">

android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: gravity = "center_vertical"
android: text = "Name:"
android: textColor = "@ color / white"
android: textSize = "15dp" />

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" />


android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: gravity = "center_vertical"
android: orientation = "horizontal"
android: paddingLeft = "60dip">

android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: gravity = "center_vertical"
android: text = "Phone:"
android: textColor = "@ color / white_two"
android: textSize = "15dp" />

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">




android: layout_width = "match_parent"
android: layout_height = "fill_parent"
android: gravity = "right"
>

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">






ExpandableListView inside by adding the following code to display the data.


ExpandableListView userlist = (ExpandableListView) findViewById (R.id.list02);

List > Groups = new ArrayList > ();
Map groupone = new HashMap ();
groupone.put ("groupname", "Technology");
Groups.add (groupone);
Map grouptwo = new HashMap ();
grouptwo.put ("groupname", "Sales");
Groups.add (grouptwo);
Map groupthree = new HashMap ();
groupthree.put ("groupname", "Personnel");
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);


------ Solution ------------------------------------ --------
I think this okay?
        <ImageView
            android:id="@+id/myCursor"
            android:layout_width="43.0dip"
            android:layout_height="58.0dip"
            android:clickable="true"
            android:onClick="你的方法名"
            android:layout_gravity="center_vertical"
            android:src="@drawable/my007" >
        </ImageView


	   public void 你的方法名 (View view) {
       //do here
    }

------ Solution ------------------------------------- -------
sorry, lose sight, you are using a simple adapter, not a custom adapter, custom to inherit BaseExpandableListAdapter, which item you want child elements:
textview = view.getviewbyid ();
String string = textView.getText (). toString ();
view is childview
string is the item content
------ reference ------------------------------ ---------
you put the adapter in the child layout code stickers, the above method is certainly not, ImageView listview is in the extended use code to get the focus before they can click on to, or focus on childview on
------ reference -------------------------------------- -
Thank you Master, thou method is feasible, but in a small pop-up window which requires the use of child item of content. This should be how to obtain it?
------ reference --------------------------------------- < br>

Thank you Master, thou method is feasible, but in a small pop-up window which requires the use of child item of content. This should be how to obtain it?
------ reference --------------------------------------- < br>

adapter Yuriko layout What does it mean! Amount embarrassed a little white
------ reference ------------------------------ ---------


Thank you, really works!
------ reference --------------------------------------- < br>

Thank you, with this idea though complex point, but better functional point!

没有评论:

发表评论