中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

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

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

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

盐池县| 林州市| 昭觉县| 阳泉市| 宿迁市| 临汾市| 道孚县| 醴陵市| 南宫市| 监利县| 海晏县| 仙居县| 自治县| 湖州市| 登封市| 临潭县| 滨海县| 临颍县| 鹤峰县| 栖霞市| 湛江市| 汉源县| 揭西县| 黑水县| 常宁市| 辉县市| 宝山区| 铜山县| 秀山| 云阳县| 西昌市| 寿光市| 锡林浩特市| 蒙山县| 潜江市| 黄大仙区| 广平县| 钟祥市| 左云县| 辉县市| 外汇|