Lately I have been working on my Shopping App. It's used commercially in the AppStore. So a few of users asked for a function to directly add an article price and finally a total price of all list items. So I tried to realise this in my app.
So I have build my listview
items = new ArrayList<String>();
adapter = new ArrayAdapter(this, R.layout.item_layout, R.id.txt, items);
listView.setAdapter(adapter);
And my listview works super. Now I want to get the position of an item in the ListView.
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
String value = (String)adapter.getItem(position);
Toast.makeText(getApplicationContext(), value, Toast.LENGTH_LONG).show();
}
});
So and now I want to add a function to override my listview item and set a new 'Price'.
And last but not least my question. How can i get a total of all prices in the ListView?
I mean (Position 1 1,99), (Position 2 1,05), (Position 3 4,50), (Total 7,54),
Thx for all of your help :D