getview方法内listview底部的按钮

时间:2019-07-18 06:54:21

标签: android android-listview android-button

我想在列表视图的末尾放置一个底部,该列表视图是可滚动的并且具有动态行。我尝试将addFooterView放置到它上,但是它可以工作,但是,当我的列表视图包含5行时,按钮的数量也是5。

如何解决这个问题?

public View getView(int i, View convertView, ViewGroup viewGroup) {
        View mView = convertView;
        String betid = mData.get(i).get("betnumber");
        ViewHolder holder;
        ListView listview = findViewById(R.id.lvMain);

        if (mView == null) {
            Context context = viewGroup.getContext();
            LayoutInflater inflater = LayoutInflater.from(context);
            mView = inflater.inflate(R.layout.row_layout, null,false);
            holder = new ViewHolder();


            mView.setTag(holder);

            holder.checkBox.setTag(i);

        } else {
            holder = (ViewHolder) mView.getTag();
            ((ViewHolder)mView.getTag()).checkBox.setTag(i);
        }

        if (betid != null) {
            int x = 0;
            String betnumber = mData.get(i).get("betnumber");
            String amountTarget = mData.get(i).get("amountTarget");
            String toSend = mData.get(i).get("toSend");
            holder.tx_amount.setText(amountTarget);
            holder.tx_number.setText(betnumber);
            holder.tx_counter.setText(String.valueOf(toSend));
        }

        ViewHolder holde2r = (ViewHolder) mView.getTag();

        for (int k = 0; k < checked.size(); k++) {
            if (checked.get(k) == i) {
                holde2r.checkBox.setChecked(true);
            }
            else if (checked.get(k) != i) {
                holde2r.checkBox.setChecked(false);
            }
        }

        return mView;
    }
    private class ViewHolder {
        TextView tx_number;
        TextView tx_amount;
        TextView tx_counter;
        CheckBox checkBox;
        EditText tx_modify;
    }


}

0 个答案:

没有答案