亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

ExpandableList一種可以伸展收縮的listview

發布時間:2020-07-16 11:57:30 來源:網絡 閱讀:1282 作者:釣伯樂 欄目:開發技術
public class OrderingExpandAdapter extends BaseExpandableListAdapter {
    public OrderingExpandAdapter(Context ctx, ArrayList<String> groupTitle,
            List<List> list, Handler handler) {
        mContext = ctx;
        mSize = BitmapUtils.getSize(ctx, 60);
        mInflater = (LayoutInflater) mContext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mHandler = handler;
        initImageLoader();
        setData(groupTitle, list);
    }
    private void setData(ArrayList<String> groupTitle, List<List> list) {
        if (groupTitle == null) {
            mGroupList = new ArrayList<String>();
        } else {
            mGroupList = groupTitle;
        }
        if (list == null) {
            mData = new ArrayList<List>();
        } else {
            mData = list;
        }
    }
    public void refreshData(ArrayList<String> groupTitle, List<List> list) {
        setData(groupTitle, list);
        notifyDataSetChanged();
    }
    public void refreshData(List<List> list) {
        setData(mGroupList, list);
        notifyDataSetChanged();
    }
    public void refreshData() {
        notifyDataSetChanged();
    }
    private void initImageLoader() {
        mImageLoader = ImageLoader.getInstance();
        options = new DisplayImageOptions.Builder()
        .showImageOnLoading(R.drawable.ic_stub)
        .showImageForEmptyUri(R.drawable.ic_empty)
        .showImageOnFail(R.drawable.ic_error).cacheInMemory(true)
        .cacheOnDisc(true).considerExifParams(true)
        .displayer(new SimpleBitmapDisplayer()).build();
    }
    public void setData(List<List> list) {
        mData = list;
    }
    @Override
    public int getGroupCount() {
        // TODO Auto-generated method stub
        return mData.size();
    }
    @Override
    public int getChildrenCount(int groupPosition) {
        // TODO Auto-generated method stub
        return mData.get(groupPosition).size();
    }
    @Override
    public List getGroup(int groupPosition) {
        // TODO Auto-generated method stub
        return mData.get(groupPosition);
    }
    @Override
    public Object getChild(int groupPosition, int childPosition) {
        // TODO Auto-generated method stub
        return mData.get(groupPosition).get(childPosition);
    }
    @Override
    public long getGroupId(int groupPosition) {
        // TODO Auto-generated method stub
        return groupPosition;
    }
    @Override
    public long getChildId(int groupPosition, int childPosition) {
        // TODO Auto-generated method stub
        return childPosition;
    }
    @Override
    public boolean hasStableIds() {
        // TODO Auto-generated method stub
        return false;
    }
//groupview中需要布局復用
    @Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        GroupViewHolder holder = null;
        if (convertView == null) {
            holder = new GroupViewHolder();
            convertView = mInflater.inflate(R.layout.auto_ordering_group_item,
                    null);
            // }
            holder.mGroupName = (TextView) convertView
                    .findViewById(R.id.tvgroupname);
            holder.mImageView = (ImageView) convertView
                    .findViewById(R.id.ivorderarrow);
            convertView.setTag(R.layout.auto_ordering_group_item, holder);
        } else {
            holder = (GroupViewHolder) convertView
                    .getTag(R.layout.auto_ordering_group_item);
        }
        if (mGroupList != null) {
            holder.mGroupName.setText(mGroupList.get(groupPosition));
        }
        if (isExpanded) {
            holder.mImageView
                    .setBackgroundResource(R.drawable.order_arrow_down);
        } else {
            holder.mImageView
                    .setBackgroundResource(R.drawable.order_arrow_right);
        }
        return convertView;
    }
//childview中需要布局復用
    @Override
    public View getChildView(int groupPosition, int childPosition,
            boolean isLastChild, View convertView, ViewGroup parent) {
        ChildViewHolder holder = null;
//這里判斷 不僅要判斷convertView為空還要判斷 getTag方面獲得布局復用為空
        if (convertView == null
                || null == (ChildViewHolder) convertView.getTag(R.id.idkey0
                        + (groupPosition+1)*1000+childPosition)) {
            holder = new ChildViewHolder();
            convertView = mInflater.inflate(R.layout.auto_ordering_child_item,
                    null);
            // }
              initViewHolder();
// setTag(key,value);鍵值對模式 使用
//key 要注意 必須再res/value/ids 中聲明定義
            convertView.setTag(R.id.idkey0 +  (groupPosition+1)*1000+childPosition, holder);
        } else {
            holder = (ChildViewHolder) convertView.getTag(R.id.idkey0
                    +  (groupPosition+1)*1000+childPosition);
        }
          initViewDataHolder();
        return convertView;
    }
    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        // TODO Auto-generated method stub
        /* 很重要:實現ChildView點擊事件,必須返回true */
        return false;
    }
    private class GroupViewHolder {
        ImageView mImageView;
        TextView mGroupName;
    }
    private class ChildViewHolder {
        // iv/ivmoreshoptitle/rlsurplustime/tvsurplustime/tvtitle/tvnowprice/tvoriginalprice
        // tvpeople/btadd0/lladd1/btminus/btmid/btminus
        ImageView ivBack;
        ImageView ivMS;
        RelativeLayout rlSurplusTime;
        TextView tvSurplusTime;
        TextView tvTitle;
        TextView tvNowPrice;
        TextView tvOriginalPrice;
        RelativeLayout rlPeople;
        TextView tvPeople;
        Button btAdd0;
        LinearLayout llAdd1;
        Button btMinus;
        Button btMid;
        Button btAdd;
    }
}

ExpandableList 這里需要3個布局:

1、在activity中的listview

2、child_item

3、group_item


include 外面要包個linearlayout

android:layout_weight="1"

可以控制scrollview的擠壓下層view,導致不顯示


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

黔南| 长岛县| 和硕县| 灵武市| 水富县| 盐津县| 万载县| 郓城县| 蒙阴县| 乌拉特后旗| 酉阳| 遂昌县| 巴南区| 仁化县| 焉耆| 田阳县| 丹东市| 利津县| 渑池县| 赞皇县| 苏尼特右旗| 芜湖市| 英德市| 烟台市| 莆田市| 甘南县| 讷河市| 沙雅县| 陇南市| 秭归县| 三明市| 黔南| 钟祥市| 木兰县| 若羌县| 县级市| 广州市| 新晃| 保靖县| 博客| 古田县|