如何能够获得我的图片---ExpandableListAdapter
在listview下嵌套了gridview,可是当我单击某一张图片的时候,怎么打开我选中的图片
package com.src.zhang.demo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.Toast;
import android.widget.SimpleAdapter;
import android.widget.TextView;
public class ListViewAdapter extends BaseExpandableListAdapter implements
OnItemClickListener {
public static final int ItemHeight = 48;// 每项的高度
public static final int PaddingLeft = 36;// 每项的高度
private int myPaddingLeft = 0;
private MyGridView 易做图Grid;
private List<String> menu_易做图_image_array = null;
private List<TreeNode> treeNodes = new ArrayList<TreeNode>();
private Context parentContext;
private LayoutInflater layoutInflater;
static public class TreeNode {
Object parent;
List<Object> childs = new ArrayList<Object>();
}
public ListViewAdapter(Context view, int myPaddingLeft) {
parentContext = view;
this.myPaddingLeft = myPaddingLeft;
}
public List<TreeNode> GetTreeNode() {
return treeNodes;
}
public void UpdateTreeNode(List<TreeNode> nodes) {
treeNodes = nodes;
}
public void RemoveAll() {
treeNodes.clear();
}
public Object getChild(int groupPosition, int childPosition) {
return treeNodes.get(groupPosition).childs.get(childPosition);
}
public int getChildrenCount(int groupPosition) {
return treeNodes.get(groupPosition).childs.size();
}
static public TextView getTextView(Context context) {
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ItemHeight);
TextView textView = new TextView(context);
textView.setLayoutParams(lp);
textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
return textView;
}
/**
* 可自定义ExpandableListView
*/
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
menu_易做图_image_array = ListViewActivity.initimage
.get(groupPosition);
if (convertView == null) {
layoutInflater = (LayoutInflater) parentContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.view, null);
易做图Grid = (MyGridView) convertView
.findViewById(R.id.GridView_易做图);
易做图Grid.setNumColumns(4);// 设置每行列数
易做图Grid.setGravity(Gravity.CENTER);// 位置居中
易做图Grid.setHorizontalSpacing(10);// 水平间隔
易做图Grid.setOnItemClickListener(this);
}
易做图Grid.setAdapter(getMenuAdapter(menu_易做图_image_array));// 设置菜单Adapter
return convertView;
}
/**
* 可自定义list
*/
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
TextView textView = getTextView(this.parentContext);
textView.setText(getGroup(groupPosition).toString());
textView.setPadding(myPaddingLeft + PaddingLeft, 0, 0, 0);
return textView;
}
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
public Object getGroup(int groupPosition) {
return treeNodes.get(groupPosition).parent;
}
public int getGroupCount() {
return treeNodes.size();
}
public long getGroupId(int groupPosition) {
return groupPosition;
}
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
public boolean hasStableIds() {
return true;
}
/**
* 构造菜单Adapter
*
* @param menuNameArray
* 名称
* @param menu_易做图_image_array2
* 图片
* @return SimpleAdapter
*/
private SimpleAdapter getMenuAdapter(List<String> menu_易做图_image_array2) {
ArrayList<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
for (int i = 1; i < menu_易做图_image_array2.size(); i++) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("itemImage", menu_易做图_image_array2.get(i));
data.add(map);
}
SimpleAdapter simperAdapter = new SimpleAdapter(parentContext, data,
R.layout.item_menu, new String[] { "itemImage" },
new int[] { R.id.item_image });
return simperAdapter;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id)
{
Toast.makeText(parentContext, "当前选中的是:" + position, Toast.LENGTH_SHORT)
.show();
}
public List<String> getgroups(int groupspos) {
imagesadpter img = new imagesadpter();
List<String> lists = new ArrayList<String>();
for (int i = 1; i < img.datatimelist.get(groupspos).size(); i++) {
lists.add(img.datatimelist.get(groupspos).get(i));
}
return lists;
}
}
我猜测在onItemClick事件做处理,但是有个问题我怎么获得选中的groupID,求思路指教 --------------------编程问答--------------------
listView.setOnChildClickListener(new OnChildClickListener() {--------------------编程问答-------------------- 如果是要传值到令一个Activity怎么做 --------------------编程问答-------------------- 什么意思
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// TODO Auto-generated method stub
return false;
}
});
不明白 你要做什么
不是有数据List数组吗 从中 获取啊
假如 想作为Intent的参数的话 必须 序列化
补充:移动开发 , Android