java - How to update listview in tab? -


I have two tabs in my app and there are list views in this tab.

I set list data in each list.

Enter image details here

I want to know from the list To delete, and click on the [x] image, from the list view.

The item has been removed from the list, but I do not know how to update the listview, I notifyDataSetChanged () in my custom adapter but not updated.

Activity for the first tab:

  Public Stable List & lt; Products & gt; MCartList; MCartList = AllProducts.getCartList (); ListViewCatalog = (ListView) findViewById (R.id.my_order_list); MProductAdapter = New CustomList Adapter (MyOrders.this, mCartList, "", true); ListViewCatalog.setAdapter (mProductAdapter);   

My custom list adapter:

  Public category adapter adapter adapter {Private layoutInfLiter Layout Inflighter; Private reference mContext; Private listing & lt; Products & gt; MProductList; Private string mtip; Private boolean mShowQuantity; Public Castelist Adapters (context reference, list & gt; product & gt; list, string type, possibility of boolean show) {layoutInflater = LayoutInflater.from (reference); MContext = Reference; MProductList = List; MShowQuantity = showQuantity; MType = Type; } @ Override Public Inaccount () {return mProductList.size (); } @OverWide public object found iTam (int position) {return M project list.jet (status); } @ Override Public Long ITMID (Status of Intake) {Return Status; } View public viewView (int position, seeviewview, viewgroup parents) {last see item item; Final difference final closing = position; If (convertView == empty) {convertView = layoutInflater.inflate (R.layout.list_row, null); Item = new viewholder (); Item.imageView = (ImageView) Convert View.findViewById (R.id.product_image); Item.name = (TextView) Convert View.findViewById (R.id.name); Item.pid = (TextView) ConvertviewFindViewID (RIDPID); Item.price = (TextView) ConvertviewfindVBIID (RIDPrice); Item.description = (TextView) ConvertviewFindvibid (R.D.Description); Item.removeProduct = (ImageView) Convert View.findViewById (R.id.removeProduct); Item.addToCart = (TextView) ConvertViewfindVBIID (Rd. Edtocard); Item.productQuantity = (TextView) Convert View.findViewById (R.id.textViewQuantity); ConvertView.setTag (item); } Else {item = (ViewHolder) ConvertViewsagent (); } Final Product curProduct = mProductList.get (status); Item.imageView.setImageDrawable (curProduct.imageView); Item.name.setText (curProduct.name); Item.pid.setText (curProduct.pid); Int length = curProduct.description.length (); Int start = 0, end = length; If (length> = 40) {start = 0; End = 40; } String s = curProduct.description.substring (start, end); Item.description.setText (s + "..."); Item.price.setText (curProduct.price + mContext.getString (r.trag. Currency)); If (mShowQuantity) {item.addToCart.setVisibility (see GONE); // item.product.quality.set text ("Quantity:" + All Products.JetProductquentity (Tax Product)); Item.productQuantity.setVisibility (View.GONE); } Other {item.productQuantity.setVisibility (see GONE); Item.removeProduct.setVisibility (View.GONE); } Item.removeProduct.setOnClickListener (See New. OnClickListener) {@Override on public void (see V) {AlertDialog.Builder ab = new AlertDialog.builder (mContext); Ab.setTitle ("Delete"); ab.setMessage ( "It will be removed from the product list.") SetPositiveButton ( "Delete", a new DialogInterface.OnClickListener () {@Override on public zero (DialogInterface dialog, int which) {curProduct.selected = false; AllProducts .removeProduct (curProduct); NotifyDataSetChanged (); NotifyDataSetInvalidated ();}}). SetNegativeButton ( "Cancel", new DialogInterface.OnClickListener () {@Override public void onClick (DialogInterface dialog, int which) {}}); Ab.create () ();}}); ItemkaddToCartksetOnClickListener (See New. OnClickListener () {@Override on public void (see V) {Intent product Vivrnviseshtya = new Intent (mContext, ProductDetail.class); productDetailsIntent.putExtra (AllProducts.PRODUCT_INDEX, final closing) ; Utpadkvivrnintent. input extras ( "type", Mtiaipi); mContext.startActivity (productDetailsIntent);}}); Return Convertview; } Public class viewer {textview pud; TextView addToCart; Textview name; Textview value; Text view description; ImageView imageView; ImageView removal product; TextView ProductsConnect; }}    

You Adisucitdeta change () list View or you can reset the setAdapter () which will be the new list value, but will be expensive later

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -