Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi, i have listview on android,i want to give textview value +1 when i click the button.
here's my adapter code:

namespace fnb.Adapters
    class listMenuAdapters : BaseAdapter<listMenuModels>, IFilterable
        private Context mContext;
        private List<listMenuModels> mItems;
        private List<listMenuModels> _originalData;
        private TextView txtNamaMenu;
        private TextView txtHargaMenu;
        private ImageView imageMenu;
        private TextView txtKodeMenu;
        private TextView txtQty;
        private ImageButton butPlusMenu;
        private ImageButton butMinMenu;

        public listMenuAdapters(Context context, List<listMenuModels> items)
            this.mItems = items;
            this.mContext = context;

            Filter = new MenuFilter(this);

        public override int Count
                return mItems.Count;

        public override listMenuModels this[int position]
                return mItems[position];

        public override long GetItemId(int position)
            return position;

        public override View GetView(int position, View convertView, ViewGroup parent)
            View row = convertView;

            if (row == null)
                row = LayoutInflater.From(mContext).Inflate(Resource.Layout.lvListMenuFnb_rowItem, null, false);

            txtNamaMenu = row.FindViewById<TextView>(Resource.Id.textMenuName);
            txtNamaMenu.Text = mItems[position].namaMenu;
            txtHargaMenu = row.FindViewById<TextView>(Resource.Id.textMenuPrice);
            txtHargaMenu.Text = mItems[position].hargaJual.ToString("N0");
            txtKodeMenu = row.FindViewById<TextView>(Resource.Id.textKodeMenu);
            txtKodeMenu.Text = mItems[position].kodeMenu;
            butPlusMenu = row.FindViewById<ImageButton>(Resource.Id.ibPlusMenuFnb);
            butPlusMenu.Focusable = false;
            butPlusMenu.FocusableInTouchMode = false;

            butMinMenu = row.FindViewById<ImageButton>(Resource.Id.ibMinusMenuFnb);
            butMinMenu.FocusableInTouchMode = false;
            butMinMenu.Focusable = false;

            txtQty = row.FindViewById<TextView>(Resource.Id.txtQtyMenuFnb);
            //txtQty.Text = "0";

            txtKodeMenu.Visibility = ViewStates.Invisible;

            imageMenu = row.FindViewById<ImageView>(Resource.Id.imageMenu);
            imageMenu.Focusable = false;
            imageMenu.FocusableInTouchMode = false;

            if (mItems[position].pic != null)


            return row;

        public static Bitmap bytesToBitmap(byte[] imageBytes)
            Bitmap bitmap = BitmapFactory.DecodeByteArray(imageBytes, 0, imageBytes.Length);
            return bitmap;

        public Filter Filter { get; private set; }

        private class MenuFilter : Filter
            private listMenuAdapters menuAdapter;

            public MenuFilter(listMenuAdapters menuAdapter)
                this.menuAdapter = menuAdapter;

            protected override FilterResults PerformFiltering(ICharSequence constraint)
                var returnObj = new FilterResults();
                var results = new List<listMenuModels>();

                if (menuAdapter._originalData == null)
                    menuAdapter._originalData = menuAdapter.mItems;

                if (constraint == null) return returnObj;

                if (menuAdapter._originalData != null && menuAdapter._originalData.Any())
                            menu => menu.namaMenu.ToLower().Contains(constraint.ToString())));

                returnObj.Values = FromArray(results.ToArray());

                return returnObj;

            protected override void PublishResults(ICharSequence constraint, FilterResults results)
                var res = new List<listMenuModels>(results.Values.ToArray<listMenuModels>());
                menuAdapter.mItems = res;

What I have tried:

I have tried to browse for the code, but cannot found
Updated 5-Jul-17 4:56am
Member 13287700 1-Jul-17 2:51am    
add +1 to txtQty

1 solution

The adapter code is mostly irrelevant (for the question you are asking).

What does the code look like that responds to the button click? In it, you'll want to make a change to one of the members of listMenuModels: namaMenu, hargaJual, or kodeMenu. The adapter code will update the TextView control with the new value.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900