ExpandableListView用法

article/2025/9/26 14:20:40

先上个效果图:


1,我用的fragment

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.dami.student.ui.chatui.adapter.ContactsExpandableListAdapter;
import com.dami.student.R;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import com.dami.student.entity.AccountInformation;
import android.widget.ExpandableListView;
import com.dami.student.entity.ClassEntity;
import com.dami.student.entity.ClassMembers;
import com.dami.student.net.database.OperationDB;
import com.dami.student.net.socket.SendDataSocketInterface;
import com.dami.student.net.socket.SocketService;
import com.dami.student.net.utils.BusinessCallbackBase;
import com.dami.student.net.utils.BusinessCallbackInterfaceUtil;
import com.dami.student.net.utils.CommandPackage;
import com.dami.student.net.utils.LogUtil;
import com.dami.student.ui.chatui.adapter.SortClassMemberAdapter;
import com.dami.student.ui.chatui.ui.activity.PrivateChatActivity;
import com.dami.student.ui.chatui.util.CharacterParser;
import com.dami.student.ui.chatui.util.ClearEditText;
import com.dami.student.ui.chatui.util.PinyinComparator;
import android.widget.ExpandableListView.OnChildClickListener;public class ContactsFragmentExpandableListView extends Fragment {private boolean isDebug = true;private String TAG = "ContactsFragmentExpandableListView";private ContactsEntityBusinessCallback mContactsEntityBusinessCallback;private View contactsFragmentView;private Context mContext;private List<List<?>> mGroupMemberList = new ArrayList<List<?>>();//群组名称     private String[] mGroup = new String[] { "家庭群", "班级群"};private List<AccountInformation> mAccountInformationList = new ArrayList<AccountInformation>();private ExpandableListView mExpandableListView;private List<ClassMembers> mClassMembersList;private ContactsExpandableListAdapter mContactsExpandableListAdapter;public ClearEditText mClearEditText;private ClassEntity mClassEntity;private int sequence;private byte[] data;private boolean flag;/*** 汉字转换成拼音的类*/private CharacterParser characterParser;/*** 根据拼音来排列ListView里面的数据类*/private PinyinComparator pinyinComparator;@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {// TODO Auto-generated method stubcontactsFragmentView = inflater.inflate(R.layout.fragment_contacts_expandablelistview,container, false);findViewById();inIt();return contactsFragmentView;}@Overridepublic void onDestroy() {// TODO Auto-generated method stubsuper.onDestroy();BusinessCallbackInterfaceUtil.remove(mContactsEntityBusinessCallback);}private Handler mHandler = new Handler() {public void handleMessage(Message msg) {switch (msg.what) {case 1:// 根据a-z进行排序//mClassMembersList = filledData(mClassMembersList);mGroupMemberList.clear();LogUtil.i(TAG, "wdh  handleMessage"+mAccountInformationList);mGroupMemberList.add(mAccountInformationList);mGroupMemberList.add(mClassMembersList);mContactsExpandableListAdapter.updateExpandableListView(mGroup,mGroupMemberList);for (int i = 0; i < mClassMembersList.size(); i++) {OperationDB.getInstance(mContext).setClassMenberEntity(mClassMembersList.get(i));}break;default:break;}};};private void findViewById() {// TODO Auto-generated method stubmExpandableListView = (ExpandableListView) contactsFragmentView.findViewById(R.id.group_expandableListView);mClearEditText = (ClearEditText) getActivity().findViewById(R.id.filter_edit);}private void inIt() {// TODO Auto-generated method stub// 实例化汉字转拼音类characterParser = CharacterParser.getInstance();pinyinComparator = new PinyinComparator();mContext = getActivity();mClassEntity = OperationDB.getInstance(mContext).QueryClassEntity();mAccountInformationList.addAll(0, OperationDB.getInstance(mContext).getUserData(0));mAccountInformationList.addAll(1, OperationDB.getInstance(mContext).getUserData(1));mGroupMemberList.add(mAccountInformationList);if (mClassEntity.className != null) {mClassMembersList = filledData(OperationDB.getInstance(mContext).QueryClassMenberEntity(1,mClassEntity.classId,mClassEntity.classId));if (null != mClassMembersList && mClassMembersList.size() != 0) {mGroupMemberList.add(mClassMembersList);}}LogUtil.i(TAG, "wdh   mGroupMemberList   "+mGroupMemberList.size());LogUtil.i(TAG, "wdh   mGroupMemberList   "+mGroupMemberList);mContactsExpandableListAdapter = new ContactsExpandableListAdapter(mContext,mGroup,mGroupMemberList);mExpandableListView.setAdapter(mContactsExpandableListAdapter);mExpandableListView.setGroupIndicator(null);mExpandableListView.setOnChildClickListener(new OnChildClickListener() {@Overridepublic boolean onChildClick(ExpandableListView parent, View v,int groupPosition, int childPosition, long id) {// TODO Auto-generated method stubObject object = mGroupMemberList.get(groupPosition).get(childPosition);LogUtil.i(TAG, "wdh   --onChildClick---- "+object);Intent intent = new Intent(mContext, PrivateChatActivity.class);if (object instanceof ClassMembers) {intent.putExtra("object", (ClassMembers)object);startActivity(intent);}else if (object instanceof AccountInformation) {ClassMembers classMembers = new ClassMembers();AccountInformation mAccountInformation = (AccountInformation)object;classMembers.setMemberId(mAccountInformation.getUserId());classMembers.setName(mAccountInformation.getUserName());classMembers.setPhone(mAccountInformation.getPhoneNum());classMembers.setHeadImg(mAccountInformation.getHeadPortrait());classMembers.setRelation(mAccountInformation.getRelation());intent.putExtra("object", classMembers);startActivity(intent);}return false;}});mContactsEntityBusinessCallback = new ContactsEntityBusinessCallback();BusinessCallbackInterfaceUtil.setCallBack(mContactsEntityBusinessCallback);// 根据输入框输入值的改变来过滤搜索mClearEditText.addTextChangedListener(new TextWatcher() {@Overridepublic void onTextChanged(CharSequence s, int start, int before,int count) {// 当输入框里面的值为空,更新为原来的列表,否则为过滤数据列表filterData(s.toString());}@Overridepublic void beforeTextChanged(CharSequence s, int start, int count,int after) {}@Overridepublic void afterTextChanged(Editable s) {}});LogUtil.i(TAG, "wdh mClassEntity.classId =" + mClassEntity.classId);sequence = SocketService.getSequence();data = CommandPackage.getInstance().queryClass(sequence,mClassEntity.classId, 0);flag = SendDataSocketInterface.sendCallBack(data, 0);if (isDebug) {Log.i(TAG,"===wdh==getDeviceId====="+ OperationDB.getInstance(getActivity()).getDeviceId() + "sequence==" + sequence+ "==flag====" + flag + "  mClassEntity.classId  "+ mClassEntity.classId);}}/*** 为ListView填充数据* * @param date* @return*/private List<ClassMembers> filledData(List<ClassMembers> classMembersList) {if (classMembersList.size() > 0) {for (int i = 0; i < classMembersList.size(); i++) {classMembersList.get(i).setName(classMembersList.get(i).getName());// 汉字转换成拼音String pinyin = characterParser.getSelling(classMembersList.get(i).getName());String sortString = pinyin.substring(0, 1).toUpperCase();// 正则表达式,判断首字母是否是英文字母if (sortString.matches("[A-Z]")) {classMembersList.get(i).setSortLetters(sortString.toUpperCase());} else {classMembersList.get(i).setSortLetters("#");}}}return classMembersList;}/*** 根据输入框中的值来过滤数据并更新ListView* * @param filterStr*/private void filterData(String filterStr) {if (null == mClassMembersList || mClassMembersList.size() < 1) {//无数据,不搜索return;}List<ClassMembers> filterDateList = new ArrayList<ClassMembers>();if (TextUtils.isEmpty(filterStr)) {filterDateList = mClassMembersList;} else {filterDateList.clear();for (ClassMembers classMembers : mClassMembersList) {String name = classMembers.getName();if (name.indexOf(filterStr.toString()) != -1|| characterParser.getSelling(name).startsWith(filterStr.toString())) {filterDateList.add(classMembers);}}}// 根据a-z进行排序Collections.sort(filterDateList, pinyinComparator);mGroupMemberList.add(mClassMembersList);mContactsExpandableListAdapter.updateExpandableListView(mGroup,mGroupMemberList);}class ContactsEntityBusinessCallback extends BusinessCallbackBase {@Overridepublic void onClassMenbers(int result,ArrayList<ClassMembers> contactsList, int sequence) {// TODO Auto-generated method stubsuper.onClassMenbers(result, contactsList, sequence);Log.i(TAG, "wdh ===contactsList.size()===" + contactsList.size());if (0 == result) {if (isDebug)Log.i(TAG, "wdh contactsList:" + contactsList);mClassMembersList = contactsList;Message message = Message.obtain();message.what = 1;mHandler.sendMessage(message);}}}}

2,adapter,当然是继承BaseExpandableListAdapter

import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import com.dami.student.net.socket.SocketService;
import com.dami.student.entity.AccountInformation;
import com.bumptech.glide.Glide;
import android.content.Intent;
import android.net.Uri;
import com.dami.student.R;
import com.dami.student.net.utils.LogUtil;
import com.dami.student.entity.ClassMembers;
import com.dami.student.ui.chatui.widget.CircleImageView;public class ContactsExpandableListAdapter extends BaseExpandableListAdapterimplements OnClickListener {private String Tag = "ContactsExpandableListAdapter";private String[] mGroup;// 大组组名private List<List<?>> mGroupMemberList; // 小组List,群组成员,可以使不同list,例如List<联系人>,List<家庭群>都可以放里面private Context mContext;private LayoutInflater mInflater;private int mGroupPosition;public ContactsExpandableListAdapter(Context context, String[] group,List<List<?>> groupMemberList) {this.mContext = context;this.mGroup = group;this.mGroupMemberList = groupMemberList;}public void updateExpandableListView(String[] group,List<List<?>> groupMemberList) {this.mGroup = group;this.mGroupMemberList = groupMemberList;notifyDataSetChanged();}//得到大组成员总数@Overridepublic int getGroupCount() {// TODO Auto-generated method stubreturn mGroup.length;}//得到小组成员的数量 @Overridepublic int getChildrenCount(int groupPosition) {// TODO Auto-generated method stubreturn mGroupMemberList.get(groupPosition).size();}//得到大组成员对象@Overridepublic Object getGroup(int groupPosition) {// TODO Auto-generated method stubreturn mGroup[groupPosition];}//得到小组成员对象@Overridepublic Object getChild(int groupPosition, int childPosition) {// TODO Auto-generated method stubreturn mGroupMemberList.get(groupPosition).get(childPosition);}//得到大组成员对象id@Overridepublic long getGroupId(int groupPosition) {// TODO Auto-generated method stubreturn groupPosition;}//得到小组成员对象id@Overridepublic long getChildId(int groupPosition, int childPosition) {// TODO Auto-generated method stubreturn childPosition;}/** * Indicates whether the child and group IDs are stable across changes to the * underlying data. * 表明大組和小组id是否稳定的更改底层数据。 * @return whether or not the same ID always refers to the same object * @see Adapter#hasStableIds() */@Overridepublic boolean hasStableIds() {// TODO Auto-generated method stubreturn false;}// 设置子列表是否可选中,保存groupPosition以便child里面的item里面的button写点击事件@Overridepublic boolean isChildSelectable(int groupPosition, int childPosition) {// TODO Auto-generated method stubLogUtil.i(Tag, "wdh  groupPosition ="+groupPosition);mGroupPosition = groupPosition;return true;}//得到大组成员的view  @Overridepublic View getGroupView(int groupPosition, boolean isExpanded,View convertView, ViewGroup parent) {// TODO Auto-generated method stubViewHolderGroup groupHolder;if (null == convertView) {convertView = mInflater.from(mContext).inflate(R.layout.expandableliseview_grorp_item, parent, false);groupHolder = new ViewHolderGroup();groupHolder.group_name_tv = (TextView) convertView.findViewById(R.id.group_name_TV);groupHolder.open_close_group_IM = (ImageView) convertView.findViewById(R.id.open_close_group_IM);convertView.setTag(groupHolder);} else {groupHolder = (ViewHolderGroup) convertView.getTag();}groupHolder.open_close_group_IM.setImageResource(isExpanded ? R.drawable.open_group:R.drawable.close_group);groupHolder.group_name_tv.setText(mGroup[groupPosition]);return convertView;}//得到小组成员的view  @Overridepublic View getChildView(int groupPosition, int childPosition,boolean isLastChild, View convertView, ViewGroup parent) {// TODO Auto-generated method stubViewHolderChild childHolder;if (null == convertView) {convertView = mInflater.from(mContext).inflate(R.layout.item_class_member, parent, false);childHolder = new ViewHolderChild();childHolder.tvTitle = (TextView) convertView.findViewById(R.id.title);childHolder.contactsPic = (CircleImageView) convertView.findViewById(R.id.contactsPic);childHolder.sendShortMessageIB = (ImageButton) convertView.findViewById(R.id.send_short_message_IB);childHolder.phoneIB = (ImageButton) convertView.findViewById(R.id.phone_IB);convertView.setTag(childHolder);} else {childHolder = (ViewHolderChild) convertView.getTag();}childHolder.sendShortMessageIB.setTag(R.id.send_short_message_IB,childPosition);childHolder.sendShortMessageIB.setOnClickListener(this);childHolder.phoneIB.setTag(R.id.phone_IB, childPosition);childHolder.phoneIB.setOnClickListener(this);LogUtil.i(Tag, "wdh ------groupPosition     "+groupPosition);Object object = mGroupMemberList.get(groupPosition).get(childPosition);LogUtil.i(Tag, "wdh ------object     "+object);if (null != object) {if (object instanceof ClassMembers) {if (null == ((ClassMembers) object).getHeadImg()) {childHolder.contactsPic.setImageResource(R.drawable.group_member_icon_default);} else {childHolder.contactsPic.setImageResource(R.drawable.group_member_icon_default);}if (((ClassMembers) object).getRelation() != null&& ((ClassMembers) object).getRelation().trim().length() > 0) {childHolder.tvTitle.setText(((ClassMembers) object).getName()+ " -- " + ((ClassMembers) object).getRelation());} else {childHolder.tvTitle.setText(((ClassMembers) object).getName());}} else if (object instanceof AccountInformation) {Glide.with(mContext).load(SocketService.FILE_UPLOAD_URL+((AccountInformation) object).getHeadPortrait()).error(mContext.getResources().getDrawable(R.drawable.group_member_icon_default)).into(childHolder.contactsPic);if (((AccountInformation) object).getRelation() != null&& ((AccountInformation) object).getRelation().trim().length() > 0) {childHolder.tvTitle.setText(((AccountInformation) object).getUserName()+ " -- " + ((AccountInformation) object).getRelation());} else {childHolder.tvTitle.setText(((AccountInformation) object).getUserName());}}}return convertView;}//大组成员private static class ViewHolderGroup {TextView group_name_tv;ImageView open_close_group_IM;}//小组成员final static class ViewHolderChild {TextView tvLetter;CircleImageView contactsPic;TextView tvTitle;ImageButton sendShortMessageIB;ImageButton phoneIB;}//小组成员里面的button@Overridepublic void onClick(View v) {// TODO Auto-generated method stubint position = 0;switch (v.getId()) {case R.id.send_short_message_IB:position = (int)v.getTag(R.id.send_short_message_IB);LogUtil.i(Tag, "wdh  位置  sendShortMessageIB" +v.getTag(R.id.send_short_message_IB)); Object object = mGroupMemberList.get(mGroupPosition).get(position);Uri uri = null;if (object instanceof ClassMembers) {uri =Uri.parse("smsto:" + ((ClassMembers)object).getPhone());}else if (object instanceof AccountInformation) {uri =Uri.parse("smsto:" + ((AccountInformation)object).getPhoneNum());}if (null != uri) {Intent shortMessageIntent = new Intent(Intent.ACTION_VIEW, uri);mContext.startActivity(shortMessageIntent); }break;case R.id.phone_IB:LogUtil.i(Tag, "wdh  位置  phoneIB" + v.getTag(R.id.phone_IB));position = (int)v.getTag(R.id.phone_IB); Object phoneObject = mGroupMemberList.get(mGroupPosition).get(position);Intent callIntent = null;if (phoneObject instanceof ClassMembers) {callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" +((ClassMembers)phoneObject).getPhone()));}else if (phoneObject instanceof AccountInformation) {callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" +((AccountInformation)phoneObject).getPhoneNum()));}if (null != callIntent) {mContext.startActivity(callIntent);}break;default:break;}}}

3,fragment布局fragment_contacts_expandablelistview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" android:background="@color/white"><ExpandableListViewandroid:id="@+id/group_expandableListView"android:layout_width="fill_parent"android:layout_height="fill_parent"android:layout_gravity="center"android:dividerHeight="1dp"android:divider="#E0E0E0" /></LinearLayout>

4,这个是大的分组的布局expandableliseview_grorp_item.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="40dp"android:gravity="center_vertical" ><ImageViewandroid:id="@+id/open_close_group_IM" android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_marginLeft="13dp"android:layout_alignParentLeft="true"android:layout_centerVertical="true"/><TextView android:id="@+id/group_name_TV"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/open_close_group_IM"android:layout_marginLeft="12dp"android:textSize="15sp"android:layout_centerVertical="true"android:textColor="#333333"/></RelativeLayout>

5,小的分组的布局,就是item布局item_class_member.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="47dp"android:gravity="center_vertical"android:descendantFocusability="blocksDescendants"android:orientation="vertical" ><TextViewandroid:id="@+id/catalog"android:layout_width="fill_parent"android:layout_height="fill_parent"android:background="#E0E0E0"android:textColor="#999999"android:layout_weight="1.0"android:paddingLeft="5dip"android:paddingTop="5dip"android:paddingBottom="5dip"android:text="@string/camera_shooting"/><LinearLayout android:layout_width="match_parent"android:layout_height="57dp"android:orientation="horizontal"android:gravity="center_vertical"><com.dami.student.ui.chatui.widget.CircleImageViewandroid:id="@+id/contactsPic"android:layout_width="41dp"android:layout_height="41dp"android:layout_marginLeft="4dp"android:layout_weight="1"></com.dami.student.ui.chatui.widget.CircleImageView><TextViewandroid:id="@+id/title"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_gravity="center_vertical"android:gravity="center_vertical"android:textColor="#333333"android:layout_weight="6"android:textSize="15sp"android:text="@string/hold_to_talk"/><ImageButton android:id="@+id/send_short_message_IB"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginRight="4dp"android:focusable="false"android:clickable="true"android:scaleType="fitXY"android:background="@drawable/send_short_message"/><ImageView android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="0.5"/><ImageButton android:id="@+id/phone_IB"android:layout_width="wrap_content"android:layout_height="wrap_content"android:focusable="false"android:clickable="true"android:scaleType="fitXY"android:background="@drawable/phone"/><ImageView android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="2"/></LinearLayout ></LinearLayout>

参考文章:https://www.aliyun.com/jiaocheng/111569.html

                https://blog.csdn.net/xyzz609/article/details/51975416

                https://blog.csdn.net/way_ping_li/article/details/7995552




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

相关文章

android expandablelistview简单应用,android ExpandableListView简单例子

android中常常要用到ListView&#xff0c;有时也要用到ExpandableListView&#xff0c;如在手机设置中&#xff0c;对于分类有很好的效果&#xff0c;会用ListView的人一定会用ExpandableListView&#xff0c;因为 ExpandableListView extends ListView的&#xff0c;下面来看个…

android expandablelistview横向,完美实现ExpandableListView二级分栏效果

本文实例为大家分享了ExpandableListView二级分栏效果的具体代码&#xff0c;供大家参考&#xff0c;具体内容如下 对ExpandableListView控件进行封装(未自定义)直接上代码&#xff1a; 通用ViewHolder类&#xff0c;仅在setImageResource中添加代码 package com.svp.haoyan.ex…

android expandablelistview横向,expandableListView 总结

实现效果图&#xff1a; expandableListView groupIndicator 图片默认是在左边&#xff0c;而且比较难看&#xff0c;而我要的是实现groupIndicator 在右边自定义图片&#xff0c; 换图片 最简单的就是直接copy 系统 android:drawable/expander_group ?android:attr/expandab…

Android学习之ExpandableListView

什么是ExpandableListView ExpandableListView是扩展的ListView&#xff0c;继承自ListView&#xff1b;ExpandableListView可以实现点击展开列表&#xff0c;再点击收缩回去的效果。 ExpandableListView的使用 首先需要在主布局文件中声明ExpandableListView&#xff1b; …

ExpandableListView详解

文章目录 效果图ExpandableListView的简介与使用去掉ExpandableListView的箭头以及自定义Indicator解决setOnChildClickListener失效问题解决collapseGroup(i)崩溃问题解决group_item.xml中包含CheckBox、EditText等&#xff0c;点击不能展开的问题 1.效果图 2.ExpandableLi…

values_list()

转载&#xff1a;https://www.cnblogs.com/chenchao1990/p/5311531.html?utm_sourcetuicool&utm_mediumreferral

列表(lists)

Lists and the things you can do with them.Includes indexing(索引&#xff09;,slicing &#xff08;切片&#xff09;and mutating&#xff08;变异&#xff09;. 1.Python 中的列表表示有序的值序列。 以下是如何创建它们的示例&#xff1a; primes [2,3,5,7] #我们可以…

Android Preference API 用法--ListPreference(一)

一&#xff0e;ListPreference简介 我们都只知道SharedPreference非常适合于参数设置功能&#xff0c;在此处的preference 也是代表SharedPreference的意思&#xff0c;在SharedPreference中&#xff0c;我们可以迅速的将某些值保存进xml文件中&#xff0c;然后我们可以读取这…

android entries属性,ListPreference需要设置两个属性:android:entries和android:entryValues...

android:defaultValue"black" android:entries"array/setting_skintheme" android:entryValues"array/setting_skintheme_value" android:key"SkinTheme" android:summary"请选择您喜欢的软件皮肤颜色" android:title"…

Android ListPreference的用法

首先&#xff0c;我们明确&#xff0c;preference是和数据存储相关的。 其次&#xff0c;它能帮助我们方便的进行数据存储&#xff01;为什么这个地方一定要强调下方便的这个词呢&#xff1f;原因是&#xff0c;我们可以根本就不使用&#xff0c;我们有另外的N种办法可以实现同…

List总结

ArrayList与LinkedList的区别是什么&#xff1f; 从继承树&#xff0c;底层数据结构&#xff0c;线程安全&#xff0c;执行效率来进行分析。 1.底层使用的数据结构 ArrayList 底层使用的是Object数组&#xff0c;初始化时就会指向的会是一个static修饰的空数组&#xff0c;数…

android Preference ListPreference EditTextPreference

android中包含Preference ListPreference EditTextPreference等控件布局的写法&#xff0c;已经操作各个控件的事件介绍&#xff0c;如下 <?xml version"1.0" encoding"utf-8"?> <PreferenceScreen xmlns:android"http://schemas.android…

Android中ListPreference的使用

这篇主要是具体例子&#xff0c;可以先看一下理论&#xff0c;网址是&#xff1a;Android中Preference的使用以及监听事件分析 我们可以先看一下效果图 我们先截取不小段布局&#xff0c;代码如下&#xff1a; <ListPreferenceandroid:defaultValue"string/usb_defaul…

list列表的用法

List&#xff08;列表&#xff09;是 Python中使用最频繁的数据类型。列表可以完成大多数集合类的数据结构实现。列表中元素的类型可以不相同&#xff0c;它支持数字&#xff0c;字符串甚至可以包含列表&#xff08;所谓嵌套&#xff09;。列表是写在方括号 [ ] 之间&#xff0…

List 列表的用法

List&#xff08;列表&#xff09; 是 Python 中使用最频繁的数据类型。列表可以完成大多数集合类的数据结构实现。列表中元素的类型可以不相同&#xff0c;它支持数字&#xff0c;字符串甚至可以包含列表&#xff08;所谓嵌套&#xff09;。列表是写在方括号 [ ] 之间、用逗号…

自定义ListPreference弹出Dialog背景

公司最近项目需求是用实体键来在应用内操作,这就需要对那些可点击的widget的背景进行自定义,使其响应focus状态随即变化。大部分的layout改动都是挺简单的。 但是遇到一个主要的问题就是自带的PreferenceFragment,里面的layout不是通过平时常用的Button ImageView那些来写的…

android之ListPreference的用法_PreferenceActivity用法

首先&#xff0c;我们明确&#xff0c;preference是和数据存储相关的。 其次&#xff0c;它能帮助我们方便的进行数据存储&#xff01;为什么这个地方一定要强调下方便的这个词呢&#xff1f;原因是&#xff0c;我们可以根本就不使用&#xff0c;我们有另外的N种办法可…

ListPreference详解与使用

listprefenence比switchpreference多了一个arrays.xml&#xff0c;这个arrays.xml就是用来写我们需要的list的内容。 以切换mode功能为例&#xff0c;就是切换协议的mode&#xff0c;一共需要五个选项。除了switchpreference中的key&#xff0c;title&#xff0c;summary和pers…

互联网协议 — TCP — 流量控制

目录 文章目录 目录TCP 流量控制流量控制处理流程 TCP 流量控制 TCP 流量控制由滑动窗口&#xff08;Sliding Window&#xff09;技术支撑。Sender 根据 Receiver 返回 ACK 中包含的 Window Size 字段来动态调整自身发送 Segments 的速率&#xff0c;以此保证收发双方不会因为…

电信网络性能质量测量

电信网络性能质量测量 作者:千里孤行(http://blog.csdn.net/yanghehong) 为什么要有质量和性能的测量 • 验证系统架构,配置 • 定位已有问题 • 及早发现潜在问题 • 为系统架构演进提供数据支持 服务质量的四个视角 服务质量的网络部分和非网络部分 从网络角度出发, QoS…