expandablelist(expandablelistview怎么用)

:暂无数据 2026-08-12 02:10:02 :0

expandablelist(expandablelistview怎么用)

大家好,如果您还对expandablelist不太了解,没有关系,今天就由本站为大家分享expandablelist的知识,包括expandablelistview怎么用的问题都会给大家分析到,还望可以解决大家的问题,下面我们就开始吧!

本文目录

expandablelistview怎么用

ExpandableListView组件是android中一个比较常用的组件,当点击一个父item的时候可以将它的子item显示出来,像手机QQ中的好友列表就是实现的类型效果。使用ExpandableListView组件的关键就是设置它的adapter,这个adapter必须继承BaseExpandbaleListAdapter类,所以实现运用ExpandableListView的核心就是学会继承这个BaseExpanableListAdapter类。

使用RecyclerView代替ListView,对于ExpandableListView怎么办

RecyclerView是一种新的视图组,目标是为任何基于适配器的视图提供相似的渲染方式。它被作为ListView和GridView控件的继承者,在最新的support-V7版本中提供支持。
在开发RecyclerView时充分考虑了扩展性,因此用它可以创建想到的任何种类的的布局。但在使用上也稍微有些不便。这就是Android——要完成一件事情总不是那么容易。
如果使用RecyclerView,你需要了解以下三个元素:
RecyclerView.Adapter
LayoutManager
ItemAnimator

RecyclerView.Adapter
RecyclerView包含了一种新型适配器。它与现在使用的适配器类似,但也稍有不同,例如它需要使用ViewHolder。使用时需要重写两个主要方法:一个用来展现视图和它的持有者,而另一个用来把数据绑定到视图上。这么做的好处是,第一种方法只有当我们真正需要创建一个新视图时才被调用,不需要检查它是否已经被回收。

ExpandableListView怎么实现不同的布局

public class ExpandableListAdapter extends BaseExpandableListAdapter {
// Client Status
private String mClient_id;
private String mClient_name;
private String mClient_realid;
private String mClient_totally;
// Stocks’s product
private String mStocks;
private String mStocks_name;
private String mStocks_counts;
private String mStocks_cost;
private String mStocks_now;
private String mStocks_mark;
// Moreprofit’s product
private String mMoreprofit;
private String mMoreprofit_name;
private String mMoreprofit_counts;
private String mMoreprofit_rate;
private String mMoreprofit_years;
private String mMoreprofit_mark;

// Pes’s product
private String mPes;
private String mPes_projects;
private String mPes_invest_amount;
private String mPes_mark;

private Context mContext;

private final int VIEW_TYPE = 3;
private final int TYPE_1 = 0;
private final int TYPE_2 = 1;
private final int TYPE_3 = 2;

private LayoutInflater mLayoutInflater;

// private HandleClick mHandleClick;
private String mProduct_what = new String { “xx类产品“, “xx收益类产品“, “xx类投资“ };
private String mProduct_what_items = {
{ “产品名称“, “持有数量“, “买入成本“, “当前净值“, “备注“ },
{ “产品名称“, “持有数量“, “年收益率“, “期限“, “备注“ }, { “项目“, “投资金额“, “备注“ } };

public ExpandableListAdapter(Context mContext) {
mLayoutInflater = LayoutInflater.from(mContext);
this.mContext = mContext;
}

public ExpandableListAdapter(Context mContext, String mClient_id,
String mClient_name, String mClient_realid, String mClient_totally,
String mStocks, String mStocks_name, String mStocks_counts,
String mStocks_cost, String mStocks_now, String mStocks_mark,
String mMoreprofit, String mMoreprofit_name,
String mMoreprofit_counts, String mMoreprofit_rate,
String mMoreprofit_years, String mMoreprofit_mark, String mPes,
String mPes_projects, String mPes_invest_amount, String mPes_mark) {
// super();
this.mClient_id = mClient_id;
this.mClient_name = mClient_name;
this.mClient_realid = mClient_realid;
this.mClient_totally = mClient_totally;
this.mStocks = mStocks;
this.mStocks_name = mStocks_name;
this.mStocks_counts = mStocks_counts;
this.mStocks_cost = mStocks_cost;
this.mStocks_now = mStocks_now;
this.mStocks_mark = mStocks_mark;
this.mMoreprofit = mMoreprofit;
this.mMoreprofit_name = mMoreprofit_name;
this.mMoreprofit_counts = mMoreprofit_counts;
this.mMoreprofit_rate = mMoreprofit_rate;
this.mMoreprofit_years = mMoreprofit_years;
this.mMoreprofit_mark = mMoreprofit_mark;
this.mPes = mPes;
this.mPes_projects = mPes_projects;
this.mPes_invest_amount = mPes_invest_amount;
this.mPes_mark = mPes_mark;
this.mContext = mContext;

mLayoutInflater = LayoutInflater.from(mContext);
}

@Override
public Object getChild(int arg0, int arg1) {
return null;
}

@Override
public long getChildId(int groupPosition, int childPosition) {
return 0;
}

public int getItemViewType(int groupPosition) {
int p = groupPosition;
if (p == 0) {
return TYPE_1;
} else if (p == 1) {
return TYPE_2;
} else if (p == 2) {
return TYPE_3;
} else {
return TYPE_1;
}
}

@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
int type = getItemViewType(groupPosition);
switch (type) {
case TYPE_1:
convertView = mLayoutInflater.inflate(R.layout.item_table, null);
TextView mProduct_name_1 = (TextView) convertView
.findViewById(R.id.product_name);
TextView mProduct_counts_1 = (TextView) convertView
.findViewById(R.id.product_count);
TextView mProduct_cost_1 = (TextView) convertView
.findViewById(R.id.product_cost);
TextView mProduct_status_1 = (TextView) convertView
.findViewById(R.id.product_status);
TextView mProduct_mark_1 = (TextView) convertView
.findViewById(R.id.product_mark);
//这里是自定义一个子item的,当position==0时显示标题栏
switch (childPosition) {
case 0:
mProduct_name_1.setText(mProduct_what_items);
mProduct_counts_1.setText(mProduct_what_items);
mProduct_cost_1.setText(mProduct_what_items);
mProduct_status_1.setText(mProduct_what_items);
mProduct_mark_1.setText(mProduct_what_items);
break;

default:
mProduct_name_1.setText(“888“);
mProduct_counts_1.setText(“888“);
mProduct_cost_1.setText(“888“);
mProduct_status_1.setText(“888“);
mProduct_mark_1.setText(“888“);
break;

}
break;

case TYPE_2:
convertView = mLayoutInflater.inflate(R.layout.item_table, null);
TextView mProduct_name_2 = (TextView) convertView
.findViewById(R.id.product_name);
TextView mProduct_counts_2 = (TextView) convertView
.findViewById(R.id.product_count);
TextView mProduct__rate_2 = (TextView) convertView
.findViewById(R.id.product_cost);
TextView mProduct__years_2 = (TextView) convertView
.findViewById(R.id.product_status);
TextView mProduct_mark_2 = (TextView) convertView
.findViewById(R.id.product_mark);
//这里是自定义一个子item的,当position==0时显示标题栏
switch (childPosition) {
case 0:
mProduct_name_2.setText(mProduct_what_items);
mProduct_counts_2.setText(mProduct_what_items);
mProduct__rate_2.setText(mProduct_what_items);
mProduct__years_2.setText(mProduct_what_items);
mProduct_mark_2.setText(mProduct_what_items);
break;

default:
mProduct_name_2.setText(“888“);
mProduct_counts_2.setText(“888“);
mProduct__rate_2.setText(“888“);
mProduct__years_2.setText(“888“);
mProduct_mark_2.setText(“888“);
break;
}

break;
case TYPE_3:
convertView = mLayoutInflater.inflate(R.layout.item_table_p, null);
TextView mProject_name_3 = (TextView) convertView
.findViewById(R.id.project_name);
TextView mProject_invest_amount_3 = (TextView) convertView
.findViewById(R.id.project_invest_amount);
TextView mProject_mark = (TextView) convertView
.findViewById(R.id.project_mark);

//这里是自定义一个子item的,当position==0时显示标题栏
switch (childPosition) {
case 0:
mProject_name_3.setText(mProduct_what_items);
mProject_invest_amount_3.setText(mProduct_what_items);
mProject_mark.setText(mProduct_what_items);
break;
default:

mProject_name_3.setText(“888“);
mProject_invest_amount_3.setText(“888“);
mProject_mark.setText(“888“);
break;
}

break;
}

return convertView;
}

@Override
public int getChildrenCount(int groupPosition) {
return 1;
}

@Override
public Object getGroup(int groupPosition) {
return null;
}

@Override
public int getGroupCount() {
return mProduct_what.length;
// return 0;
}

@Override
public long getGroupId(int groupPosition) {
return 0;
}

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
int type = getItemViewType(groupPosition);
switch (type) {
case TYPE_1:
convertView = mLayoutInflater.inflate(R.layout.header_table, null);
TextView mProduct_what_1 = (TextView) convertView
.findViewById(R.id.product_what_1);

mProduct_what_1.setText(mProduct_what[groupPosition]);

break;

case TYPE_2:
convertView = mLayoutInflater
.inflate(R.layout.header_table_f, null);
TextView mProduct_what_2 = (TextView) convertView
.findViewById(R.id.product_what_2);

mProduct_what_2.setText(mProduct_what[groupPosition]);

break;
case TYPE_3:
convertView = mLayoutInflater
.inflate(R.layout.header_table_p, null);
TextView mProject_what_3 = (TextView) convertView
.findViewById(R.id.project_what_3);

mProject_what_3.setText(mProduct_what[groupPosition]);

break;
}
return convertView;
}

@Override
public boolean hasStableIds() {
return false;
}

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return false;
}

}

怎么实现两个expandablelistview上下放置

Android中ExpandableListView的使用ExpandableListView是android中可以实现下拉list的一个控件,具体的实现方法如下:首先:在layout的xml文件中定义一个ExpandableListViewviewplaincopytoclipboardprint?定义两个List,用来存放控件中Group/Child中的Stringviewplaincopytoclipboardprint?privateListgroupArray;privateList》childArray;对这两个List进行初始化,并插入一些数据viewplaincopytoclipboardprint?groupArray=newArrayList();childArray=newArrayList》();groupArray.add(“第一行“);groupArray.add(“第二行“);ListtempArray=newArrayList();tempArray.add(“第一条“);tempArray.add(“第二条“);tempArray.add(“第三条“);for(intindex=0;index

关于expandablelist,expandablelistview怎么用的介绍到此结束,希望对大家有所帮助。

expandablelist(expandablelistview怎么用)

本文编辑:admin

更多文章:


repercussions(都是余波,repercussions和aftermath有什么区别啊)

repercussions(都是余波,repercussions和aftermath有什么区别啊)

今天给各位分享都是余波,repercussions和aftermath有什么区别啊的知识,其中也会对都是余波,repercussions和aftermath有什么区别啊进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

2026年10月11日 09:00

dropdownlist 绑定(DropDownList 绑定所有项 并 显示指定项)

dropdownlist 绑定(DropDownList 绑定所有项 并 显示指定项)

本篇文章给大家谈谈dropdownlist 绑定,以及DropDownList 绑定所有项 并 显示指定项对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

2026年10月11日 08:50

协方差计算公式(协方差的计算公式)

协方差计算公式(协方差的计算公式)

这篇文章给大家聊聊关于协方差计算公式,以及协方差的计算公式对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。

2026年10月11日 08:10

易语言网页api接口怎么调用(易语言,怎么读取网页json的api)

易语言网页api接口怎么调用(易语言,怎么读取网页json的api)

本篇文章给大家谈谈易语言网页api接口怎么调用,以及易语言,怎么读取网页json的api对应的知识点,文章可能有点长,但是希望大家可以阅读完,增长自己的知识,最重要的是希望对各位有所帮助,可以解决了您的问题,不要忘了收藏本站喔。

2026年10月11日 08:00

majority of(the majority of 和 a majority of的区别以及用法例句)

majority of(the majority of 和 a majority of的区别以及用法例句)

这篇文章给大家聊聊关于majority of,以及the majority of 和 a majority of的区别以及用法例句对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。

2026年10月11日 07:40

汉字机内码查询表(1个汉字的机内码是几位谢谢)

汉字机内码查询表(1个汉字的机内码是几位谢谢)

大家好,关于汉字机内码查询表很多朋友都还不太明白,不过没关系,因为今天小编就来为大家分享关于1个汉字的机内码是几位谢谢的知识点,相信应该可以解决大家的一些困惑和问题,如果碰巧可以解决您的问题,还望关注下本站哦,希望对各位有所帮助!

2026年10月11日 07:20

promote翻译(英语翻译倡导怎么说)

promote翻译(英语翻译倡导怎么说)

其实promote翻译的问题并不复杂,但是又很多的朋友都不太了解英语翻译倡导怎么说,因此呢,今天小编就来为大家分享promote翻译的一些知识,希望可以帮助到大家,下面我们一起来看看这个问题的分析吧!

2026年10月11日 06:30

用手机如何导航?开车用手机导航哪个软件最好

用手机如何导航?开车用手机导航哪个软件最好

今天给各位分享用手机如何导航的知识,其中也会对用手机如何导航进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

2026年10月11日 06:20

多线程技术有什么用(多线程有什么作用)

多线程技术有什么用(多线程有什么作用)

其实多线程技术有什么用的问题并不复杂,但是又很多的朋友都不太了解多线程有什么作用,因此呢,今天小编就来为大家分享多线程技术有什么用的一些知识,希望可以帮助到大家,下面我们一起来看看这个问题的分析吧!

2026年10月11日 05:40

another time(another time和other time的区别)

another time(another time和other time的区别)

大家好,another time相信很多的网友都不是很明白,包括another time和other time的区别也是一样,不过没有关系,接下来就来为大家分享关于another time和another time和other time的区

2026年10月11日 05:00

最近更新

repercussions(都是余波,repercussions和aftermath有什么区别啊)
2026-10-11 09:00:05 浏览:0
dropdownlist 绑定(DropDownList 绑定所有项 并 显示指定项)
2026-10-11 08:50:04 浏览:0
majority of(the majority of 和 a majority of的区别以及用法例句)
2026-10-11 07:40:02 浏览:0
热门文章

标签列表