开发学院手机开发Android 开发 Android ExpandableListView / ExpandableListAct... 阅读

Android ExpandableListView / ExpandableListActivity 使用及数据更新

 2010-08-21 06:33:00 来源:WEB开发网   
核心提示:addInfo("kandyli",new String[]{"12345"});}public void addInfo(String p,String[] c){group.add(p);List item = new ArrayList();for(int i=0;i<

addInfo("kandyli",new String[]{"12345"});

}

public void addInfo(String p,String[] c){

group.add(p);

List item = new ArrayList();

for(int i=0;i< p>

item.add(c[i]);

}

child.add(item);

}

public void initialData(){

group = new ArrayList();

child = new ArrayList>();

addInfo("griffinshi", new String[]{"13776117119","man","Jiangsu"});

addInfo("lancewu",new String[]{"1321134","man","Taiwan"});

addInfo("kandyli",new String[]{"12345"});

}

public void addInfo(String p,String[] c){

group.add(p);

List item = new ArrayList();

for(int i=0;i< p>

item.add(c[i]);

}

child.add(item);

}

3. 定义BaseExpandableListAdapter 并与List List> 数据相适配

Java代码

public class InfoDetailsAdapter extends BaseExpandableListAdapter {

Activity activity;

public InfoDetailsAdapter(Activity a){

activity = a;

}

//child method stub

@Override

public Object getChild(int groupPosition, int childPosition) {

// TODO Auto-generated method stub

return child.get(groupPosition).get(childPosition);

}

@Override

public long getChildId(int groupPosition, int childPosition) {

// TODO Auto-generated method stub

return childPosition;

}

@Override

public int getChildrenCount(int groupPosition) {

// TODO Auto-generated method stub

return child.get(groupPosition).size();

上一页  1 2 3 4 5 6 7  下一页
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接