I have a textview txtQuantity in my panel activity. I wrote a separate class for the user adapter that will contain the products sold.
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dashboard); list = (ListView) findViewById(R.id.listSoldItems); txtAmount = (TextView) findViewById(R.id.txtAmount); txtItems = (TextView) findViewById(R.id.txtItems); // init listview adapter = new Sold_item_adaptor(Dashboard.this, soldItemsList); list.setAdapter(adapter);
I can remove items from the list using the adapter. Code for deleting items is written to the adapter class.
public View getView(final int position, View convertView, ViewGroup parent) { View vi = convertView; if (convertView == null) vi = inflater.inflate(R.layout.list_row_sold_item, null); TextView txtListItem = (TextView) vi.findViewById(R.id.txtListItem); final TextView txtQuantity = (TextView) vi.findViewById(R.id.txtQuantity); ImageView imgCancel = (ImageView) vi.findViewById(R.id.imgCancel); HashMap<String, String> mapData = new HashMap<String, String>(); mapData = data.get(position); txtListItem.setText(mapData.get("product")); txtQuantity.setText(mapData.get("qty")); imgCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { doButtonOneClickActions(txtQuantity, position); } }); return vi; } private void doButtonOneClickActions(TextView txtQuantity, int rowNumber) { // Do the actions for Button one in row rowNumber (starts at zero) data.remove(rowNumber); notifyDataSetChanged(); }
In my activity on the dashboard, I support the number of selected items, the total amount. Now, if I remove an item from the list, the code from the user adapter removes the item, but how can I get a notification / signal about the activity of the toolbar to update the quantity.
android android-activity android-listview listview
Paritosh
source share