日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android_ExpandableListView 下拉列表使用

發布時間:2025/6/15 编程问答 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android_ExpandableListView 下拉列表使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

總結一下ExpandableListView的使用


ExpandableListView與ListView用法差不多,它也有自己的適配器,可以根據自己的需求繼承BaseExpandableListAdapter,自己寫適配器


先上效果圖


和ListView用法差不多,從項目中摘的代碼

[java]?view plaincopy
  • ?<span?style="white-space:pre">???????</span>inEditText?=?(EditText)?findViewById(R.id.infusion_et_in);??
  • ??
  • e_lv?=?(ExpandableListView)?findViewById(R.id.infusion_elv);??
  • ??
  • e_lv.setAdapter(new?InfusionParentAdapter(getApplication()));??
  • [java]?view plaincopy
  • public?class?InfusionParentAdapter?extends?BaseExpandableListAdapter?{??
  • ??
  • ????private?Context?context;??
  • ????private?String[]?generalsTypes?=?new?String[]?{?"張三",?"李四"?};??
  • ????private?String[][]?generals?=?new?String[][]?{?{?"1",?"2",?"3"?},??
  • ????????????{?"4",?"5",?"6"?}?};??
  • ??
  • ????public?InfusionParentAdapter()?{??
  • ????}??
  • ??
  • ????public?InfusionParentAdapter(Context?context)?{??
  • ????????this.context?=?context;??
  • ????}??
  • ??
  • ????@Override??
  • ????public?Object?getChild(int?groupPosition,?int?childPosition)?{??
  • ????????//?TODO?Auto-generated?method?stub??
  • ????????return?generals[groupPosition][childPosition];??
  • ????}??
  • ??
  • ????@Override??
  • ????public?long?getChildId(int?groupPosition,?int?childPosition)?{??
  • ????????//?TODO?Auto-generated?method?stub??
  • ????????return?childPosition;??
  • ????}??
  • ??
  • ????@Override??
  • ????public?View?getChildView(int?groupPosition,?int?childPosition,??
  • ????????????boolean?isLastChild,?View?convertView,?ViewGroup?parent)?{??
  • ????????//?TODO?Auto-generated?method?stub??
  • ????????convertView?=?LayoutInflater.from(context).inflate(??
  • ????????????????R.layout.list_item_child,?null);??
  • ????????return?convertView;??
  • ????}??
  • ??
  • ????@Override??
  • ????public?int?getChildrenCount(int?groupPosition)?{??
  • ????????//?TODO?Auto-generated?method?stub??
  • ????????return?generals[0].length;??
  • ????}??
  • ??
  • ????@Override??
  • ????public?Object?getGroup(int?groupPosition)?{??
  • ????????//?TODO?Auto-generated?method?stub??
  • ????????return?generalsTypes[groupPosition];??
  • ????}??
  • ??
  • ????@Override??
  • ????public?int?getGroupCount()?{??
  • ????????//?TODO?Auto-generated?method?stub??
  • ????????return?generalsTypes.length;??
  • ????}??
  • ??
  • ????@Override??
  • ????public?long?getGroupId(int?groupPosition)?{??
  • ????????//?TODO?Auto-generated?method?stub??
  • ????????return?groupPosition;??
  • ????}??
  • ??
  • ????@Override??
  • ????public?View?getGroupView(int?groupPosition,?boolean?isExpanded,??
  • ????????????View?convertView,?ViewGroup?parent)?{??
  • ????????//?TODO?Auto-generated?method?stub??
  • ????????convertView=LayoutInflater.from(context).inflate(R.layout.list_item_infusion_elistview,?null);??
  • ????????return?convertView;??
  • ????}??
  • ??
  • ????@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?false;??
  • ????}??
  • ??
  • }??
  • 其中parent表示擴展的ListView,Child表示下拉列表的內容,其余的跟ListView用法一樣了

    總結

    以上是生活随笔為你收集整理的android_ExpandableListView 下拉列表使用的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。