统计列表中的项目总数在ListView [英] Count Total Number of List Items in a ListView
本文介绍了统计列表中的项目总数在ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何计算列表中的项目总数在ListView?
How to count Total Number of List Items in a ListView ?
我写一个教会在其中应用我正在使用填充存储到SD卡的图像列表中,但现在我要计算列表中的项目总数。
I am writing a Church Application in which i am populating list using images stored into SD Card, but now i want to count total number of list items.
// to upload whole list
for(int position = 0; position < lstView.getAdapter().getCount(); position++)
{
flags.put(position, true);
}
((BaseAdapter) lstView.getAdapter()).notifyDataSetChanged();
}
});
/*** Get Images from SDCard ***/
listSDCardImages = fetchSDCardImages();
// ListView and imageAdapter
lstView = (ListView) findViewById(R.id.listSDCardImages);
lstView.setAdapter(new ListSDCardImagesAdapter(this));
Toast.makeText(getApplicationContext(), "Total number of Items are:" + String.valueOf(position), Toast.LENGTH_LONG).show();
}
每次我得到的 0
推荐答案
总列表视图计数
lstView.getAdapter().getCount() ,
因此,使用
Toast.makeText(getApplicationContext(), "Total number of Items are:" + lstView.getAdapter().getCount() , Toast.LENGTH_LONG).show();
这篇关于统计列表中的项目总数在ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文