最近我一直在研究我的购物应用程序。它在AppStore中用于商业用途。 因此,一些用户要求提供直接添加文章价格和最终所有列表项目的总价格的功能。所以我试图在我的应用程序中实现这一点。Android计算ListView项目
所以我建立我的ListView
items = new ArrayList<String>();
adapter = new ArrayAdapter(this, R.layout.item_layout, R.id.txt, items);
listView.setAdapter(adapter);
而我的列表视图工作超。现在我想要在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();
}
});
所以,现在我想添加一个功能覆盖我的列表视图项,并设置一个新的“价格”。
最后但并非最不重要的是我的问题。我怎样才能得到ListView中的所有价格?
我的意思是 (位置1 1,99), (位置2 1,05), (位置3 4,50), (共7,54),
THX对于所有的帮助:d
您使用自定义适配器类项目?如果不是,您需要使用自定义适配器来实现您的要求。示例[链接](http://stackoverflow.com/questions/8166497/custom-adapter-for-list-view) –