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...