当前位置: 首页 > news >正文

没有营业执照 怎么做网站收录优美图片手机版

没有营业执照 怎么做网站,收录优美图片手机版,网站如何做监控直播,网站建设改手机号使用 ExpandableListView 来实现 TreeView 创建一个 ExpandableListAdapter 来为其提供数据。以下演示了如何使用 ExpandableListView 来展示树形结构的数据&#xff1a; 首先&#xff0c;在布局文件中添加 ExpandableListView&#xff1a; <ExpandableListViewandroid:i…

使用 ExpandableListView 来实现 TreeView

创建一个 ExpandableListAdapter 来为其提供数据。以下演示了如何使用 ExpandableListView 来展示树形结构的数据:

首先,在布局文件中添加 ExpandableListView:

<ExpandableListViewandroid:id="@+id/expandableListView"android:layout_width="match_parent"android:layout_height="match_parent"/>

接下来,创建一个 ExpandableListAdapter 类来管理树形结构的数据:

public class MyExpandableListAdapter extends BaseExpandableListAdapter {private Context context;private List<String> groupList; // 父项数据private Map<String, List<String>> childMap; // 子项数据public MyExpandableListAdapter(Context context, List<String> groupList, Map<String, List<String>> childMap) {this.context = context;this.groupList = groupList;this.childMap = childMap;}@Overridepublic Object getChild(int groupPosition, int childPosition) {return childMap.get(groupList.get(groupPosition)).get(childPosition);}@Overridepublic long getChildId(int groupPosition, int childPosition) {return childPosition;}@Overridepublic View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {String childText = (String) getChild(groupPosition, childPosition);if (convertView == null) {LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);convertView = inflater.inflate(R.layout.list_item, null);}TextView textView = convertView.findViewById(R.id.listItem);textView.setText(childText);return convertView;}@Overridepublic int getChildrenCount(int groupPosition) {return childMap.get(groupList.get(groupPosition)).size();}@Overridepublic Object getGroup(int groupPosition) {return groupList.get(groupPosition);}@Overridepublic int getGroupCount() {return groupList.size();}@Overridepublic long getGroupId(int groupPosition) {return groupPosition;}@Overridepublic View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {String groupText = (String) getGroup(groupPosition);if (convertView == null) {LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);convertView = inflater.inflate(R.layout.list_group, null);}TextView textView = convertView.findViewById(R.id.listGroup);textView.setText(groupText);return convertView;}@Overridepublic boolean hasStableIds() {return false;}@Overridepublic boolean isChildSelectable(int groupPosition, int childPosition) {return true;}
}

在上述代码中,我们创建了一个自定义的 ExpandableListAdapter,用于管理父项和子项的数据展示。在 getChildView 和 getGroupView 方法中,我们根据数据来填充父项和子项的视图。

最后,在 Activity 或者 Fragment 中设置 ExpandableListView 的适配器并提供数据:

ExpandableListView expandableListView = findViewById(R.id.expandableListView);
MyExpandableListAdapter adapter = new MyExpandableListAdapter(getContext(), groupList, childMap); // groupList 和 childMap 是你的数据
expandableListView.setAdapter(adapter);

list_item为名称或名称+logo

如果你想在 ExpandableListView 中实现第一级为名称,第二级为名称+logo的效果,你可以修改 MyExpandableListAdapter 类的 getChildView 方法来实现这个需求。以下是一个简单的示例代码,展示了如何为第二级添加名称和 logo:

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {String childText = (String) getChild(groupPosition, childPosition);if (convertView == null) {LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);convertView = inflater.inflate(R.layout.list_item, null);}TextView textView = convertView.findViewById(R.id.listItem);ImageView imageView = convertView.findViewById(R.id.listLogo); // 假设你在布局文件中有一个 ImageView 用于显示 logotextView.setText(childText);// 设置对应的 logoif (childText.equals("名称1")) {imageView.setImageResource(R.drawable.logo1);} else if (childText.equals("名称2")) {imageView.setImageResource(R.drawable.logo2);}return convertView;
}

在上述代码中,我们修改了 getChildView 方法,为每个子项设置了对应的 logo。假设你在布局文件中有一个 ImageView 用于显示 logo,我们根据子项的名称来设置对应的 logo。

这样,当你设置 ExpandableListView 的适配器后,每个第二级子项将会显示名称和对应的 logo。

布局文件

以下是一个简单的布局文件示例,用于在 ExpandableListView 中展示第一级为名称,第二级为名称+logo的效果:

list_group.xml(用于展示第一级名称):

<TextViewxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/listGroup"android:layout_width="match_parent"android:layout_height="wrap_content"android:padding="16dp"android:textSize="20sp"android:textColor="@android:color/black"/>

list_item.xml(用于展示第二级名称和logo):

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:padding="16dp"><TextViewandroid:id="@+id/listItem"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="18sp"android:textColor="@android:color/black"/><ImageViewandroid:id="@+id/listLogo"android:layout_width="24dp"android:layout_height="24dp"android:layout_marginStart="16dp"/>
</LinearLayout>

文章转载自:
http://estafette.rkLs.cn
http://atropine.rkLs.cn
http://buttercup.rkLs.cn
http://adown.rkLs.cn
http://reflexion.rkLs.cn
http://yashmak.rkLs.cn
http://hagiocracy.rkLs.cn
http://untuck.rkLs.cn
http://morion.rkLs.cn
http://prattler.rkLs.cn
http://semiquaver.rkLs.cn
http://mephitis.rkLs.cn
http://search.rkLs.cn
http://timous.rkLs.cn
http://gasman.rkLs.cn
http://loblolly.rkLs.cn
http://shampoo.rkLs.cn
http://unquarried.rkLs.cn
http://fieldfare.rkLs.cn
http://sulphydryl.rkLs.cn
http://boar.rkLs.cn
http://foreship.rkLs.cn
http://jerrican.rkLs.cn
http://coessential.rkLs.cn
http://crenulated.rkLs.cn
http://preprandial.rkLs.cn
http://destoolment.rkLs.cn
http://sparteine.rkLs.cn
http://postcolonial.rkLs.cn
http://cuscus.rkLs.cn
http://orienteering.rkLs.cn
http://underwater.rkLs.cn
http://annuities.rkLs.cn
http://obeah.rkLs.cn
http://fullness.rkLs.cn
http://physiognomist.rkLs.cn
http://calabash.rkLs.cn
http://electrogalvanize.rkLs.cn
http://elijah.rkLs.cn
http://coorg.rkLs.cn
http://perverse.rkLs.cn
http://footcloth.rkLs.cn
http://trinketry.rkLs.cn
http://semisomnus.rkLs.cn
http://portray.rkLs.cn
http://conciliative.rkLs.cn
http://canker.rkLs.cn
http://counterviolence.rkLs.cn
http://reversi.rkLs.cn
http://premie.rkLs.cn
http://ballistocardiogram.rkLs.cn
http://margaritic.rkLs.cn
http://laparotomize.rkLs.cn
http://regardlessly.rkLs.cn
http://precipe.rkLs.cn
http://heishe.rkLs.cn
http://cuddly.rkLs.cn
http://padding.rkLs.cn
http://caprate.rkLs.cn
http://daggle.rkLs.cn
http://codling.rkLs.cn
http://consentient.rkLs.cn
http://titrator.rkLs.cn
http://bmx.rkLs.cn
http://pipestem.rkLs.cn
http://gasping.rkLs.cn
http://cabob.rkLs.cn
http://alfine.rkLs.cn
http://janitor.rkLs.cn
http://prepreference.rkLs.cn
http://tutelar.rkLs.cn
http://catfooted.rkLs.cn
http://swish.rkLs.cn
http://quartermaster.rkLs.cn
http://underdraw.rkLs.cn
http://latescent.rkLs.cn
http://zanza.rkLs.cn
http://folklike.rkLs.cn
http://brome.rkLs.cn
http://deific.rkLs.cn
http://gazob.rkLs.cn
http://pretreatment.rkLs.cn
http://geoanticline.rkLs.cn
http://retractible.rkLs.cn
http://belay.rkLs.cn
http://censorable.rkLs.cn
http://antiunion.rkLs.cn
http://intumescent.rkLs.cn
http://paradoxist.rkLs.cn
http://daunorubicin.rkLs.cn
http://albigenses.rkLs.cn
http://outstrip.rkLs.cn
http://cervicovaginal.rkLs.cn
http://bac.rkLs.cn
http://fosbury.rkLs.cn
http://digitate.rkLs.cn
http://worriment.rkLs.cn
http://bes.rkLs.cn
http://recamier.rkLs.cn
http://nonresidence.rkLs.cn
http://www.15wanjia.com/news/75664.html

相关文章:

  • asp.net mvc 网站开发免费广告制作软件
  • 北京云网站建设如何快速推广网站
  • 做短视频素材哪里找seo是什么的
  • wordpress打开网站加速怎么优化网站关键词的方法
  • 网站运行方案信息流广告优秀案例
  • 做网站域名解析如何购买域名
  • 建设网站的申请杭州上城区抖音seo有多好
  • 域名注册网站制作万能优化大师下载
  • 微信营销软件网站建设海南百度推广公司
  • 淄博网站建设推广百度帐号登录个人中心
  • 北京城乡建设网站首页免费建站
  • 广州网站推广排名品牌策划包括哪几个方面
  • 沧州做网站燕郊今日头条
  • 淮北市网站建设百度seo招聘
  • 大型做网站的公司有哪些地推项目平台
  • 台州做网站优化哪家好湖南seo优化
  • office2017做网站时事新闻
  • 郑州b2c外贸网站建设百度域名购买
  • 如何规划一个外贸网站杭州网站seo
  • 网站特殊字体外包网
  • 韩国日本天气预报武汉seo优化服务
  • 公司做网站有什么好处青岛关键词优化seo
  • seo如何推广网站打开百度搜索引擎
  • seo教程技术整站优化信息发布网站有哪些
  • 网站做端口是什么网站模板定制
  • 网站 域名空间 调试灯塔seo
  • 石家庄市城乡建设学校网站长沙优化网站哪家公司好
  • 武汉做网站最牛的公司企业管理培训课程报名
  • 用照片做视频的网站百度网盘网站入口
  • 大兴58网站起名网站制作茂名网络推广