ExpandableListView说明及其用法

article/2025/11/4 8:33:06

一:ExpandableListView
ExpandableListView,是可展开的列表组件的ExpandableListView的用法和ListView非常像,只是其所显示的列表项应该由ExpandableListAdapter提供,下面是它的xml属性及说明:

  1. childDivider:指定各组内子项列表项之间的分割条
  2. childIndicator:显示在子列表项旁边的Drawable对象
  3. groupIndicator:显示在组列表项旁边的Drawable对象

二:效果

在这里插入图片描述
三:使用
第一步:新建包,列表中显示的数据是从网络请求过来,并且插入到数据库中
在这里插入图片描述
1.Android开发中使用Bean类最多的场景是从网络获取数据,将数据以Bean类组织,Bean类中的数据用于填充UI界面中的控件。此处使用Bean类主要是组织数据方便,便于将其中的数据填充到控件中。

2.biz是Business的缩写,实际上就是控制层,控制层的主要作用就是协调model层和view层直接的调用和转换。能够有效的避免请求直接进行数据库内容调用,而忽略了逻辑处理的部分。实际上biz就起到了一个server服务的角色,很好的沟通了上层和下层直接的转换,避免在model层进行业务处理(代码太混乱,不利于维护)

第二步:代码编写

1.Chapter.javapackage com.hanjie.expandablelistview2.bean;import java.util.ArrayList;
import java.util.List;public class Chapter {private int id;private String name;public static final String TABLE_NAME = "tb_chapter";public static final String COL_ID = "_id";public static final String COL_NAME = "name";private List<ChapterItem> children = new ArrayList<>();public Chapter() {}public Chapter(int id, String name) {this.name = name;this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public List<ChapterItem> getChildren() {return children;}public void addChild(ChapterItem child) {children.add(child);child.setPid(getId());}public void addChild(int id, String childName) {ChapterItem chapterItem = new ChapterItem(id, childName);chapterItem.setPid(getId());children.add(chapterItem);}public int getId() {return id;}public void setId(int id) {this.id = id;}}2.ChapterItem.javapackage com.hanjie.expandablelistview2.bean;
​
​
​
public class ChapterItem {private int id;private String name;private int pid;public static final String TABLE_NAME = "tb_chapter_item";public static final String COL_ID = "_id";public static final String COL_PID = "pid";public static final String COL_NAME = "name";public ChapterItem() {}public ChapterItem(int id, String name) {this.name = name;this.id = id;}public int getId() {return id;}public int getPid() {return pid;}public void setPid(int pId) {this.pid = pId;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}
}3.ChapterLab.javapackage com.hanjie.expandablelistview2.bean;import java.util.ArrayList;
import java.util.List;
​
​
​
public class ChapterLab {public static List<Chapter> generateDatas() {
​List<Chapter> chapters = new ArrayList<>();
​
​Chapter root1 = new Chapter(1, "Android");Chapter root2 = new Chapter(2, "IOS");Chapter root3 = new Chapter(3, "Unity 3D");Chapter root4 = new Chapter(4, "Cocos2d-x");
​root1.addChild(1, "PullToRefresh");root1.addChild(2, "Android 8.0通知栏解决方案");root1.addChild(4, "Android 与WebView的js交互");root1.addChild(8, "Android UiAutomator 2.0 入门实战");root1.addChild(10, "移动端音频视频入门");
​root2.addChild(11, "iOS开发之LeanCloud");root2.addChild(12, "iOS开发之传感器");root2.addChild(13, "iOS开发之网络协议");root2.addChild(14, "iOS之分享集成");root2.addChild(15, "iOS之FTP上传");
​
​root3.addChild(16, "Unity 3D 翻牌游戏开发");root3.addChild(17, "Unity 3D基础之变体Transform");root3.addChild(20, "带你开发类似Pokemon Go的AR游戏");root3.addChild(21, "Unity 3D游戏开发之脚本系统");root3.addChild(22, "Unity 3D地形编辑器");
​
​root4.addChild(25, "Cocos2d-x游戏之七夕女神抓捕计划");root4.addChild(26, "Cocos2d-x游戏开发初体验-C++篇");root4.addChild(27, "Cocos2d-x全民俄罗斯");root4.addChild(28, "Cocos2d-x坦克大战");root4.addChild(30, "新春特辑-Cocos抢红包");
​
​chapters.add(root1);chapters.add(root2);chapters.add(root3);chapters.add(root4);return chapters;}}4.ChapterBiz.javapackage com.hanjie.expandablelistview2.biz;import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
​
​
import com.hanjie.expandablelistview2.bean.Chapter;
import com.hanjie.expandablelistview2.bean.ChapterItem;
import com.hanjie.expandablelistview2.dao.ChapterDao;
import com.hanjie.expandablelistview2.utils.HttpUtils;import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;import java.util.ArrayList;
import java.util.List;import static android.database.sqlite.SQLiteDatabase.CONFLICT_REPLACE;/*** Created by baidu on 2018/6/10.*/public class ChapterBiz {private ChapterDao chapterDao = new ChapterDao();public void loadDatas(final Context context, final CallBack callBack,final boolean useCache) {AsyncTask<Boolean, Void, List<Chapter>> asyncTask= new AsyncTask<Boolean, Void, List<Chapter>>() {private Exception ex;@Overrideprotected void onPostExecute(List<Chapter> chapters) {if (ex != null) {callBack.loadFailed(ex);} else {callBack.loadSuccess(chapters);}}@Overrideprotected List<Chapter> doInBackground(Boolean... booleans) {final List<Chapter> chapters = new ArrayList<>();try {// 从缓存中取if (booleans[0]) {chapters.addAll(chapterDao.loadFromDb(context));}Log.d("hanjie", "loadFromDb -> " + chapters);if (chapters.isEmpty()) {// 从网络获取final List<Chapter> chaptersFromNet = loadFromNet(context);// 缓存在数据库chapterDao.insertToDb(context, chaptersFromNet);Log.d("hanjie", "loadFromNet -> " + chaptersFromNet);chapters.addAll(chaptersFromNet);}} catch (final Exception e) {e.printStackTrace();ex = e;}return chapters;}};asyncTask.execute(useCache);}public static interface CallBack {void loadSuccess(List<Chapter> chapterList);void loadFailed(Exception ex);}public List<Chapter> loadFromNet(Context context) {// final String url = "https://www.wanandroid.com/tools/mockapi/2/mooc-expandablelistview";final String url = "https://www.imooc.com/api/expandablelistview";
​String content = HttpUtils.doGet(url);final List<Chapter> chapterList = parseContent(content);// 缓存到数据库chapterDao.insertToDb(context, chapterList);return chapterList;}private List<Chapter> parseContent(String content) {
​List<Chapter> chapters = new ArrayList<>();try {JSONObject jsonObject = new JSONObject(content);int errorCode = jsonObject.optInt("errorCode");if (errorCode == 0) {JSONArray jsonArray = jsonObject.optJSONArray("data");for (int i = 0; i < jsonArray.length(); i++) {JSONObject chapterJson = jsonArray.getJSONObject(i);int id = chapterJson.optInt("id");String name = chapterJson.optString("name");Chapter chapter = new Chapter(id, name);chapters.add(chapter);
​JSONArray chapterItems = chapterJson.optJSONArray("children");for (int j = 0; j < chapterItems.length(); j++) {JSONObject chapterItemJson = chapterItems.getJSONObject(j);id = chapterItemJson.optInt("id");name = chapterItemJson.optString("name");ChapterItem chapterItem = new ChapterItem(id, name);chapter.addChild(chapterItem);}}}} catch (JSONException e) {e.printStackTrace();}return chapters;}}5.ChapterDao.javapackage com.hanjie.expandablelistview2.dao;import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
​
​
import com.hanjie.expandablelistview2.bean.Chapter;
import com.hanjie.expandablelistview2.bean.ChapterItem;
import com.hanjie.expandablelistview2.db.ChapterDbHelper;import java.util.ArrayList;
import java.util.List;import static android.database.sqlite.SQLiteDatabase.CONFLICT_REPLACE;/*** Created by baidu on 2018/6/15.*/public class ChapterDao {
​
​public List<Chapter> loadFromDb(Context context) {ChapterDbHelper dbHelper = ChapterDbHelper.getInstance(context);SQLiteDatabase db = dbHelper.getWritableDatabase();
​List<Chapter> chapterList = new ArrayList<>();Chapter chapter = null;Cursor cursor = db.rawQuery("select * from " + Chapter.TABLE_NAME, null);while (cursor.moveToNext()) {chapter = new Chapter();int id = cursor.getInt(cursor.getColumnIndex(Chapter.COL_ID));String name = cursor.getString(cursor.getColumnIndex(Chapter.COL_NAME));chapter.setId(id);chapter.setName(name);chapterList.add(chapter);}cursor.close();
​ChapterItem chapterItem = null;for (Chapter tmpChapter : chapterList) {int pid = tmpChapter.getId();cursor = db.rawQuery("select * from " + ChapterItem.TABLE_NAME + " where " + ChapterItem.COL_PID + " = ? ", new String[]{pid + ""});while (cursor.moveToNext()) {chapterItem = new ChapterItem();int id = cursor.getInt(cursor.getColumnIndex(ChapterItem.COL_ID));String name = cursor.getString(cursor.getColumnIndex(ChapterItem.COL_NAME));chapterItem.setId(id);chapterItem.setName(name);chapterItem.setPid(pid);tmpChapter.addChild(chapterItem);}cursor.close();}return chapterList;}public void insertToDb(Context context, List<Chapter> chapters) {if (chapters == null || chapters.isEmpty()) {return;}ChapterDbHelper dbHelper = ChapterDbHelper.getInstance(context);SQLiteDatabase db = dbHelper.getWritableDatabase();
​db.beginTransaction();
​ContentValues cv = null;for (Chapter chapter : chapters) {cv = new ContentValues();cv.put(Chapter.COL_ID, chapter.getId());cv.put(Chapter.COL_NAME, chapter.getName());db.insertWithOnConflict(Chapter.TABLE_NAME, null, cv, CONFLICT_REPLACE);
​List<ChapterItem> chapterItems = chapter.getChildren();for (ChapterItem chapterItem : chapterItems) {cv = new ContentValues();cv.put(ChapterItem.COL_ID, chapterItem.getId());cv.put(ChapterItem.COL_NAME, chapterItem.getName());cv.put(ChapterItem.COL_PID, chapter.getId());db.insertWithOnConflict(ChapterItem.TABLE_NAME, null, cv, CONFLICT_REPLACE);}}db.setTransactionSuccessful();db.endTransaction();}
}6.ChapterDbHelper.javapackage com.hanjie.expandablelistview2.db;import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;import com.hanjie.expandablelistview2.bean.Chapter;
import com.hanjie.expandablelistview2.bean.ChapterItem;
​
​
​
​
public class ChapterDbHelper extends SQLiteOpenHelper {
​
​private static final String DB_NAME = "db_chapter.db";private static final int VERSION = 1;private static ChapterDbHelper sInstance;public ChapterDbHelper(Context context) {super(context, DB_NAME, null, VERSION);}public static synchronized ChapterDbHelper getInstance(Context context) {if (sInstance == null) {sInstance = new ChapterDbHelper(context.getApplicationContext());}return sInstance;}@Overridepublic void onCreate(SQLiteDatabase db) {db.execSQL("CREATE TABLE IF NOT EXISTS " + Chapter.TABLE_NAME + " ("+ Chapter.COL_ID + " INTEGER PRIMARY KEY, "+ Chapter.COL_NAME + " VARCHAR"+ ")");
​db.execSQL("CREATE TABLE IF NOT EXISTS " + ChapterItem.TABLE_NAME + " ("+ ChapterItem.COL_ID + " INTEGER PRIMARY KEY, "+ ChapterItem.COL_NAME + " VARCHAR, "+ ChapterItem.COL_PID + " INTEGER"+ ")");}@Overridepublic void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}
}7.HttpUtils.javapackage com.hanjie.expandablelistview2.utils;import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;/*** Http请求的工具类*/
public class HttpUtils {private static final int TIMEOUT_IN_MILLIONS = 5000;public interface CallBack {void onRequestComplete(String result);}
​
​/*** 异步的Get请求** @param urlStr* @param callBack*/public static void doGetAsyn(final String urlStr, final CallBack callBack) {new Thread() {public void run() {try {String result = doGet(urlStr);if (callBack != null) {callBack.onRequestComplete(result);}} catch (Exception e) {e.printStackTrace();}};}.start();}
​
​/*** Get请求,获得返回数据** @param urlStr* @return* @throws Exception*/public static String doGet(String urlStr) {URL url = null;HttpURLConnection conn = null;InputStream is = null;ByteArrayOutputStream baos = null;try {url = new URL(urlStr);conn = (HttpURLConnection) url.openConnection();conn.setReadTimeout(TIMEOUT_IN_MILLIONS);conn.setConnectTimeout(TIMEOUT_IN_MILLIONS);conn.setRequestMethod("GET");conn.setRequestProperty("accept", "*/*");conn.setRequestProperty("connection", "Keep-Alive");if (conn.getResponseCode() == 200) {is = conn.getInputStream();baos = new ByteArrayOutputStream();int len = -1;byte[] buf = new byte[128];while ((len = is.read(buf)) != -1) {baos.write(buf, 0, len);}baos.flush();return baos.toString();}} catch (Exception e) {e.printStackTrace();} finally {try {if (is != null)is.close();} catch (IOException e) {}try {if (baos != null)baos.close();} catch (IOException e) {}conn.disconnect();}return null;}}
8.ChapterAdapter.javapackage com.hanjie.expandablelistview2;import android.content.Context;import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.TextView;
​
​
import com.hanjie.expandablelistview2.bean.Chapter;import java.util.List;
​
​
​
public class ChapterAdapter extends BaseExpandableListAdapter {private Context mContext;private List<Chapter> mDatas;private LayoutInflater mInflater;public ChapterAdapter(Context context, List<Chapter> chapters) {mContext = context;mDatas = chapters;mInflater = LayoutInflater.from(context);}
​
​@Overridepublic int getGroupCount() {return mDatas.size();}@Overridepublic int getChildrenCount(int groupPosition) {return mDatas.get(groupPosition).getChildren().size();}@Overridepublic Object getGroup(int groupPosition) {return mDatas.get(groupPosition);}@Overridepublic Object getChild(int groupPosition, int childPosition) {return mDatas.get(groupPosition).getChildren().get(childPosition);}@Overridepublic long getGroupId(int groupPosition) {return groupPosition;}@Overridepublic long getChildId(int groupPosition, int childPosition) {return childPosition;}
​
​// TODO@Overridepublic boolean hasStableIds() {return false;}@Overridepublic View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
​
​ParentViewHolder vh;if (convertView == null) {// 修改item height即可演示,第二个参数作用convertView = mInflater.inflate(R.layout.item_parent_chapter, parent, false);vh = new ParentViewHolder();vh.tv = convertView.findViewById(R.id.id_tv_parent);vh.iv = convertView.findViewById(R.id.id_indicator_group);convertView.setTag(vh);} else {vh = (ParentViewHolder) convertView.getTag();}vh.tv.setText(mDatas.get(groupPosition).getName());vh.iv.setSelected(isExpanded);return convertView;}@Overridepublic View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
​
​ChildViewHolder vh;if (convertView == null) {convertView = mInflater.inflate(R.layout.item_child_chapter, parent, false);vh = new ChildViewHolder();vh.tv = convertView.findViewById(R.id.id_tv_child);
​convertView.setTag(vh);} else {vh = (ChildViewHolder) convertView.getTag();}vh.tv.setText(mDatas.get(groupPosition).getChildren().get(childPosition).getName());return convertView;}// 控制child item不可点击@Overridepublic boolean isChildSelectable(int groupPosition, int childPosition) {return true;}public static class ParentViewHolder {TextView tv;ImageView iv;}public static class ChildViewHolder {TextView tv;}}9.MainActivity.javapackage com.hanjie.expandablelistview2;
​
​
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ExpandableListView;
​
​
import androidx.appcompat.app.AppCompatActivity;import com.hanjie.expandablelistview2.bean.Chapter;
import com.hanjie.expandablelistview2.biz.ChapterBiz;import java.util.ArrayList;
import java.util.List;public class MainActivity extends AppCompatActivity {private Button mBtnRefresh;private ExpandableListView mExpandableListView;private ChapterAdapter mAdapter;private List<Chapter> mDatas = new ArrayList<>();@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);
​mExpandableListView = findViewById(R.id.id_expandable_listview);mBtnRefresh = findViewById(R.id.id_btn_refresh);//        mDatas = ChapterLab.generateDatas();mAdapter = new ChapterAdapter(this, mDatas);mExpandableListView.setAdapter(mAdapter);initEvents();loadDatas(true);
​
​}private ChapterBiz mChapterBiz = new ChapterBiz();private void loadDatas(boolean useCache) {mChapterBiz.loadDatas(this, new ChapterBiz.CallBack() {@Overridepublic void loadSuccess(List<Chapter> chapterList) {Log.e("zhy", "loadSuccess  ");
​mDatas.clear();mDatas.addAll(chapterList);mAdapter.notifyDataSetChanged();}@Overridepublic void loadFailed(Exception ex) {ex.printStackTrace();Log.e("zhy", "loadFailed ex= " + ex.getMessage());}}, useCache);}private void initEvents() {
​mBtnRefresh.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {loadDatas(false);}});
​
​mExpandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {@Overridepublic boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {Log.d("zhy", "onGroupClick groupPosition = " + groupPosition);return false;}});
​
​mExpandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {@Overridepublic boolean onChildClick(ExpandableListView parent, View v,int groupPosition, int childPosition, long id) {Log.d("zhy", "onChildClick groupPosition = "+ groupPosition + " , childPosition = " + childPosition + " , id = " + id);return false;}});
​mExpandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {// 收回@Overridepublic void onGroupCollapse(int groupPosition) {Log.d("zhy", "onGroupCollapse groupPosition = " + groupPosition);}});
​mExpandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {// 展开@Overridepublic void onGroupExpand(int groupPosition) {Log.d("zhy", "onGroupExpand groupPosition = " + groupPosition);}});
​mExpandableListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> parent, View view, int position, long id) {Log.d("zhy", "onItemClick position = " + position);}});
​
​}
}10.activity_main.xml
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"><ExpandableListViewandroid:id="@+id/id_expandable_listview"android:layout_width="match_parent"android:layout_height="match_parent"android:groupIndicator="@null"android:indicatorLeft="0dp"android:indicatorRight="56dp"tools:context="com.imooc.expandablelistview_imooc.MainActivity"></ExpandableListView><Buttonandroid:id="@+id/id_btn_refresh"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="right|bottom"android:layout_margin="20dp"android:text="刷新" />
</FrameLayout>
11.item_child_chapter.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/id_tv_child"android:layout_width="match_parent"android:layout_height="40dp"android:gravity="center_vertical"android:textSize="16sp">
</TextView>12.item_parent_chapter.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:background="#44337dd7"android:layout_height="56dp"android:orientation="horizontal"><ImageViewandroid:id="@+id/id_indicator_group"android:layout_width="24dp"android:layout_height="24dp"android:layout_gravity="center_vertical"android:background="@drawable/indicator_group"/>
​
​<TextViewandroid:id="@+id/id_tv_parent"android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center_vertical"tools:text="Android"android:textSize="24dp"android:textStyle="bold"></TextView></LinearLayout>13.ic_launcher_foreground.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"><!--<item android:drawable="@drawable/indicator_expand" android:state_expanded="true" />--><item android:drawable="@drawable/indicator_expand" android:state_selected="true" /><item android:drawable="@drawable/indicator_collapse" />
</selector>
​图片可使用自己的

http://chatgpt.dhexx.cn/article/UYXuT7gm.shtml

相关文章

关于ExpandableListView用法的一个简单小例子

喜欢显示好友QQ那样的列表&#xff0c;可以展开&#xff0c;可以收起&#xff0c;在android中&#xff0c;以往用的比较多的是listview&#xff0c;虽然可以实现列表的展示&#xff0c;但在某些情况下&#xff0c;我们还是希望用到可以分组并实现收缩的列表&#xff0c;那就要用…

ExpandableListView扩展(BaseExpandableListAdapter的使用)

针对普通的ExpandableListView的使用&#xff0c;即&#xff0c;需要显示的数据全都是使用TextView显示时&#xff0c;我们使用SimpleExpandableListAdapter就可以了。 但是如果是相对复杂的ExpandableListView&#xff0c;那么SimpleExpandableListAdapter就不满足我们的要求…

ExpandableListView控件的使用

目录 一、ExpandableListView的介绍 二、适配器&#xff08;ExpandableAdapter&#xff09; 1、BaseExpandableListAdapter&#xff1a; BaseExpandableListAdapter例子 一、ExpandableListView的介绍 ExpandableListView是ListView的子类。它是ListView的基础上进行了扩展&…

ExpandableListView的使用详解

在Android开发中&#xff0c;我们知道经常会用到ListView来加载一些列表数据&#xff0c;但有时候ListView并不能完全十分满足我们的需求。比如如下图的效果用 ExpandableListView实现起来就更方便点&#xff0c;我们直接用ExpandableListView&#xff0c;设置Group不能点击即可…

ExpandableListView实例

先来看效果图&#xff1a; demo中有三个group item和多个child item&#xff0c;group item包括一个指示器&#xff0c;一个标题和一个按钮。child item包括一个图片&#xff0c;一个标题和一个按钮。先来实现布局文件 1 activity_main.xml <?xml version"1.0&qu…

ExpandableListView使用方法详解

一、前言 “好记性不如烂笔头”&#xff0c;再次验证了这句话是真的很有道理啊&#xff0c;一个月前看了一下ExpandableListView的使用&#xff0c;今天再看居然忘了这个是干啥的了&#xff0c;今天就详细讲解一下ExpandableListView的使用方法&#xff0c;感觉对于二级条目显示…

ExpandableList的使用

首先&#xff0c;我们把一二级选择的对应的类写好。 看这些代码&#xff0c;最主要的是我在ParentStrings中写了一个List<ChildrenStrings>的一个方法&#xff0c;以便之后ChildrenStrings的存储和调用 下面是BusAdapter继承BaseExpandableAdapter public class BusAda…

可折叠列表ExpandableList

ExpandableList就是可展开的ListView 首先我们来看一下页面的布局 expandlist_layout.xml文件 <RelativeLayoutxmlns:android"http://schemas.android.com/apk/res/android"xmlns:app"http://schemas.android.com/apk/res-auto"xmlns:tools"htt…

Adapter类控件使用之ExpandableList(可折叠式列表)的基本使用

(一)概述 本节要讲解的Adapter类控件是ExpandableListView,就是可折叠的列表,它是 ListView的子类, 在ListView的基础上它把应用中的列表项分为几组,每组里又可包含多个列表项。至于 样子, 类似于QQ联系人列表,他的用法与ListView非常相似,只是ExpandableListViv…

如果在临汾遇见你

哈 如果在临汾遇见你&#xff0c;那么&#xff0c;我们一定要去平阳南街煤化巷口的宾库西餐厅&#xff0c;坐在只需消费15块钱就可以坐一整天的大厅散座上&#xff0c;聊着我们相见恨晚的话题。 如果在临汾遇见你&#xff0c;那么&#xff0c;我们一定要去传说的尧庙&#xff0…

吃完7家互联网大厂食堂,我回去就把老板开了

本文转载自 超人测评 不会还有人不知道&#xff08;中文&#xff09;字节跳动&#xff08;英文&#xff09;Bytedance的工牌&#xff0c;已经成为年轻人的社交货币了吧。 有人说它是“相亲市场的硬通货”&#xff0c;也有人将它称为“2021年最潮流时尚单品”。每当你在奶茶店…

围剿宏光MINI

NEW 关注Tech逆向思维视频号 最新视频→【做核酸&#xff1f;打疫苗&#xff1f;3分钟假期安全出行攻略】 出品&#xff5c;深途 文&#xff5c;黎明 编辑&#xff5c; 魏佳 有很长一段时间&#xff0c;汽车企业的老板和投资人&#xff0c;都热衷于造“大车”。蔚来、小鹏、威马…

《植物大战僵尸》的12个成功秘诀

口述 / James Gwertzman 整理 / 杨东杰 [caption id"attachment_6675" align"alignleft" width"263" caption"James Gwertzman PopCap亚太区总裁"] [/caption] 4月28日&#xff0c;在由长城会和CSDN联合主办的“开发者星球——TUP大…

只要10分钟,搭建属于个人的炫酷网站,你还在犹豫什么?

&#x1f482; 个人主页: IT学习日记&#x1f91f; 版权: 本文由【IT学习日记】原创、在CSDN首发、需要转载请联系博主&#x1f4ac; 如果文章对你有帮助、欢迎关注、点赞、收藏(一键三连)和订阅专栏哦&#x1f485; 想寻找共同成长的小伙伴&#xff0c;请点击【技术圈子】 文章…

我的股票投资原则:专注业绩好、看得懂的消费品行业

本文概要&#xff1a;文以载道。总结了过往的经验教训&#xff0c;明确了未来的投资方向和股票投资圈。 我是一名Java程序员&#xff0c;今年心情有点烦躁&#xff0c;没怎么有耐心写工作之外的代码。 同时&#xff0c;我也是一名业余投资人&#xff0c;所以今年就又花了大量…

最近回了趟家,随便拍的照片

先贴下家对面的东山。呵呵。看上去光秃秃的。不过我看上去只有很深的亲切。 家里盖被子的东西 我大哥房间里面别人送的&#xff0d;&#xff0d;&#xff0d;堆绣  是我们湟中的一种农民搞的艺术品 家里的酸奶。  呵呵&#xff0c;大家很多人都记得西宁街头的那种勺子挖着…

破解网址_中国目前的破解组织大全

中国目前的破解组织大全&#xff08;2009版&#xff09;——[TFW]find31作品 管理提醒&#xff1a; 本帖被 朕很伤心 从 『 风云AD区 』 移动到本区(2009-06-23) 破解组织前管理员告诉你中国目前的破解组织现状——看了某个N年前的帖子而发&#xff0c;说实话我真的不忍心再看…

推荐 10 个不错的网络监视工具

点击上方“民工哥技术之路”选择“置顶或星标” 每天10点为你分享不一样的干货 有几个网络监视工具可以用于不同的操作系统。在这篇文章中&#xff0c;我们将讨论从 Linux 终端中运行的 10 个网络监视工具。 它对不使用 GUI 而希望通过 SSH 来保持对网络管理的用户来说是非常理…

【Java】Socket网络编程实现内网穿透、端口映射转发、内网穿透上网工具的编写,设置IP白名单防火墙

这里写目录标题 简介更新 一、背景1.1 情景假设1.2 想要达到的目的1.3 局限1.3 解决方案一&#xff08;路由器NAT&#xff09;1.4 解决方案二&#xff08;云服务器转发&#xff09; 二、方案介绍2.1 方案简介2.2 具体流程2.3 编程要点2.4 关于web管理IP白名单的更新2.5 关于soc…

计算机网络--Windows网络测试工具

实验目的 理解上述知识点所涉及的基本概念并学会使用这些工具测试网络的状态及从网上获取信息。 实验环境 安装了TCP/IP协议的Windows系统&#xff0c;包含实用的网络工具。 实验内容 完成下列要求&#xff0c;并记录实验步骤和结果 1、 检测本机的MAC地址 2、 检测本机网…