expandablelist仿微信朋友圈
Ⅰ 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 proct
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 proct
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 proct
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[] mProct_what = new String[] { "xx类产品", "xx收益类产品", "xx类投资" };
private String[][] mProct_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 mProct_name_1 = (TextView) convertView
.findViewById(R.id.proct_name);
TextView mProct_counts_1 = (TextView) convertView
.findViewById(R.id.proct_count);
TextView mProct_cost_1 = (TextView) convertView
.findViewById(R.id.proct_cost);
TextView mProct_status_1 = (TextView) convertView
.findViewById(R.id.proct_status);
TextView mProct_mark_1 = (TextView) convertView
.findViewById(R.id.proct_mark);
//这里是自定义一个子item的,当position==0时显示标题栏
switch (childPosition) {
case 0:
mProct_name_1.setText(mProct_what_items[0][0]);
mProct_counts_1.setText(mProct_what_items[0][1]);
mProct_cost_1.setText(mProct_what_items[0][2]);
mProct_status_1.setText(mProct_what_items[0][3]);
mProct_mark_1.setText(mProct_what_items[0][4]);
break;
default:
mProct_name_1.setText("888");
mProct_counts_1.setText("888");
mProct_cost_1.setText("888");
mProct_status_1.setText("888");
mProct_mark_1.setText("888");
break;
}
break;
case TYPE_2:
convertView = mLayoutInflater.inflate(R.layout.item_table, null);
TextView mProct_name_2 = (TextView) convertView
.findViewById(R.id.proct_name);
TextView mProct_counts_2 = (TextView) convertView
.findViewById(R.id.proct_count);
TextView mProct__rate_2 = (TextView) convertView
.findViewById(R.id.proct_cost);
TextView mProct__years_2 = (TextView) convertView
.findViewById(R.id.proct_status);
TextView mProct_mark_2 = (TextView) convertView
.findViewById(R.id.proct_mark);
//这里是自定义一个子item的,当position==0时显示标题栏
switch (childPosition) {
case 0:
mProct_name_2.setText(mProct_what_items[1][0]);
mProct_counts_2.setText(mProct_what_items[1][1]);
mProct__rate_2.setText(mProct_what_items[1][2]);
mProct__years_2.setText(mProct_what_items[1][3]);
mProct_mark_2.setText(mProct_what_items[1][4]);
break;
default:
mProct_name_2.setText("888");
mProct_counts_2.setText("888");
mProct__rate_2.setText("888");
mProct__years_2.setText("888");
mProct_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(mProct_what_items[2][0]);
mProject_invest_amount_3.setText(mProct_what_items[2][1]);
mProject_mark.setText(mProct_what_items[2][2]);
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 mProct_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 mProct_what_1 = (TextView) convertView
.findViewById(R.id.proct_what_1);
mProct_what_1.setText(mProct_what[groupPosition]);
break;
case TYPE_2:
convertView = mLayoutInflater
.inflate(R.layout.header_table_f, null);
TextView mProct_what_2 = (TextView) convertView
.findViewById(R.id.proct_what_2);
mProct_what_2.setText(mProct_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(mProct_what[groupPosition]);
break;
}
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return false;
}
}
Ⅱ ExpandableListView子ListView背景可以设置吗
你可以自己写一个布局文件啊,那样的话,你就可以按照自己的喜好来设置listview的背景了!!!不明白的话可以我可以给你贴一段代码!!!
Ⅲ 安卓怎么实现expandablelistvew的子项滑动,group不滑动
ExpandableList怎样实现滑动子项时父项不动 ExpandableListView是android中可以实现下拉list的一个控件,是一个垂直滚动的心事两个级别列表项手风琴试图,列表项是来自ExpandableListViewaAdapter,组可以单独展开。 重要方法: expandGroup (int groupPos) ;//在分组列表视图中 展开一组, setSelectedGroup (int groupPosition) ;//设置选择指定的组。 setSelectedChild (int groupPosition, int childPosition, boolean shouldExpandGroup);//设置选择指定的子项。 getPackedPositionGroup (long packedPosition);//返回所选择的组 getPackedPositionForChild (int groupPosition, int childPosition) ;//返回所选择的子项 getPackedPositionType (long packedPosition);//返回所选择项的类型(Child,Group) isGroupExpanded (int groupPosition);//判断此组是否展开 expandableListView.setDivider();这个是设定每个Group之间的分割线。 expandableListView.setGroupIndicator();这个是设定每个Group之前的那个图标。 expandableListView.collapseGroup(int group); 将第group组收起 ExpandableListAdapter 一个接口,将基础数据...
Ⅳ ExpandableListView 的数据会重复添加论坛还没人问这个
版主在吗?我发几个帖子都没人气了..都是看的人多,你来顶一下不?
Ⅳ android ExpandableListView点击二级菜单中textview怎么实现获取textview中值
getExpandableListView().setOnChildClickListener(new OnChildClickListener() {
/**
* 参数1:控件的父对象
* 参数2:子的行布局对象
* 参数3:子节点所在的组的索引
* 参数4:子节点的索引。
*/
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
Toast.makeText(MainActivity.this, child_list.get(groupPosition).get(childPosition).get("name"), 1).show();
return false;
}
});
Ⅵ Android ExpandableListView中二级列表item数据重复怎么解决。
列表复用出问题了,应该在getView方法里处理好不同情况下的控件设值问题。
Ⅶ 写一个ExpandableListView实现点击效果
配置 listSector
Ⅷ expandablelistview自定义布局问题
请教一个问题 我在做expandablelistview时 我使用的适配器是继承BaseExpandableListAdapter的,同时在该适配器中getChildView使用自定义的布局,布局中加了一个button按钮,现在的问题是button可单击但OnChildClickListener不能处理单击事件,还请大侠们指教,谢谢!
Ⅸ ExpandableListView子ListView背景可以设置吗
这个问题没有正确答案,但我必须要选一个错误的做为最佳答案吗?这样会误导别人的,但不选又要被扣分,希望eoe的管理员解决一下这个bug
Ⅹ android中ExpandableListView展开与缩放
可以。解决方案Github pull request链接: Android的原生提供和展开分组的ListView:ExpandableListView,然而相比于iOS上原生提供的UITableView,其UI能力不足,比如没有原生的动画展开和收起效果支持。 在开源代码社区我们可以找到几个为Andro...