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

Android ExpandableListView / ExpandableListActivity 使用及数据更新

 2010-08-21 06:33:00 来源:WEB开发网   
核心提示:View convertView, ViewGroup parent) {// TODO Auto-generated method stubString string = group.get(groupPosition);return getGenericView(string);}//View stub to cr

View convertView, ViewGroup parent) {

// TODO Auto-generated method stub

String string = group.get(groupPosition);

return getGenericView(string);

}

//View stub to create Group/Children 's View

public TextView getGenericView(String s) {

// Layout parameters for the ExpandableListView

AbsListView.LayoutParams lp = new AbsListView.LayoutParams(

ViewGroup.LayoutParams.FILL_PARENT, 64);

TextView text = new TextView(activity);

text.setLayoutParams(lp);

// Center the text vertically

text.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);

// Set the text starting position

text.setPadding(36, 0, 0, 0);

text.setText(s);

return text;

}

@Override

public boolean hasStableIds() {

// TODO Auto-generated method stub

return false;

}

@Override

public boolean isChildSelectable(int groupPosition, int childPosition) {

// TODO Auto-generated method stub

return true;

}

}

4. emulator 运行截图:

5. 下面说一下 数据更新 问题 包括:添加数据 删除数据

* 定义添加数据界面:add.xml

Xml代码

< ?xml version="1.0" encoding="utf-8"?>

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="horizontal"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

上一页  1 2 3 4 5 6 7 8 9 10  下一页
赞助商链接