Answer the question
In order to leave comments, you need to log in
How to access the function of the main activity from the ListAdapter?
Big brothers please tell a beginner andorid developer, I am using a ListView with an ArrayAdapter installed as a way to display data.
In the layout line that the adapter uses, 2 buttons "+1" and "-1" are set, which change the number in their own line.
The buttons work fine, but in the main form I want to calculate the total for all rows of the ArrayList.
Button press listeners are located in the adapter class. I can't find how I can update the total after clicking a button in a row.
I tried to do in main activity:
productList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View v, int position, long arg3) { SetSumAsTitle(); } });
But the event doesn't fire.
Answer the question
In order to leave comments, you need to log in
The general idea is this - the adapter should not steer it.
Process click events in the logic layer, change the model (list) and update the display in the view.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question