android 随手记代码,用ExpandableListView写的随手记实例
效果圖:
核心代碼:
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.member_listview, null);
}
//一級列表中顯示的標題
TextView txtFather = (TextView) view.findViewById(R.id.txtFather);
txtFather.setText(getGroup(groupPosition).toString());
return view;
}
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.member_childitem, null);
}
//類別
final TextView txtAccountType = (TextView) view
.findViewById(R.id.txtAccountType);
txtAccountType.setText(accountChild.get(groupPosition).get(childPosition)
.get(ExListView.FATHERACCOUNT).toString());
//子類別
final TextView txtChildType = (TextView) view.findViewById(R.id.txtChildType);
txtChildType.setText(accountChild.get(groupPosition).get(childPosition)
.get(ExListView.CHILDACCOUNT).toString());
//余額
TextView txtBalance = (TextView) view.findViewById(R.id.txtBalance);
txtBalance.setText(accountChild.get(groupPosition).get(childPosition)
.get(ExListView.BALANCEACCOUNT).toString());
ImageView imgDraw = (ImageView) view.findViewById(R.id.imgDraw);
imgDraw.setBackgroundResource(R.drawable.icon_drag);
return view;
}
源代碼為:
轉載:http://www.adobex.com/android/source/details/00000388.htm
總結
以上是生活随笔為你收集整理的android 随手记代码,用ExpandableListView写的随手记实例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android主板接口定义,范例解析:学
- 下一篇: unity发布android报错,Uni