将数组列表的大小显示到文本视图
Display the size of an arraylist to a textview
我想在文本视图中显示 ArrayList 的大小。
Textview textView;
ArrayList<Integer> mList = new ArrayList<>();
if(mList.size() < 7)
{
mList.add(1);
mList.add(2);
mList.add(3);
}
textView.setText(mList.size());
它给我异常:
android.content.res.Resources$NotFoundException: String resource ID #0x2
你可以使用..
textView.setText(""+mList.size());
或
textView.setText(String.valueOf(mList.size()));
或
textView.setText(mList.size().toString());
将我的回答标记为已接受。
我想在文本视图中显示 ArrayList 的大小。
Textview textView;
ArrayList<Integer> mList = new ArrayList<>();
if(mList.size() < 7)
{
mList.add(1);
mList.add(2);
mList.add(3);
}
textView.setText(mList.size());
它给我异常:
android.content.res.Resources$NotFoundException: String resource ID #0x2
你可以使用..
textView.setText(""+mList.size());
或
textView.setText(String.valueOf(mList.size()));
或
textView.setText(mList.size().toString());
将我的回答标记为已接受。