【发布时间】:2014-09-09 08:51:52
【问题描述】:
我在其中创建了一个类,我使用了一个 arraylist hashmap 和 int 计数器变量 如果我想从这个类中清除所有值意味着类变量没有任何值。这里我向你展示我是如何将值存储在列表和计数器变量中的。
我想清除循环类变量中的所有值。
Roundlooping.java
public class Roundlooping {
ArrayList<HashMap<String, String>> list;
int counter;
}
Mainactivity.java
Roundlooping rl = new Roundlooping();
ArrayList<HashMap<String, String>> odata = new ArrayList<HashMap<String,String>>();
ArrayList<Roundlooping> data = new ArrayList<Roundlooping>();
if (cursor.moveToFirst())
{
do
{
HashMap<String, String> map = new HashMap<String, String>();
map.put(DB_Constant.MYFILES.FILE_TIMERFROM, cursor.getString(cursor.getColumnIndex(DB_Constant.MYFILES.FILE_TIMERFROM)));
map.put(DB_Constant.MYFILES.FILE_TIMERTO, cursor.getString(cursor.getColumnIndex(DB_Constant.MYFILES.FILE_TIMERTO)));
map.put(DB_Constant.MYFILES.FILE_STUDIOFORMAT, cursor.getString(cursor.getColumnIndex(DB_Constant.MYFILES.FILE_STUDIOFORMAT)));
odata.add(map);
rl.list=odata;
if(odata.size()>5)
{
rl.counter=odata.size();
data.add(rl);
}
else
{
rl.counter=0;
data.add(rl);
}
} while (cursor.moveToNext());
}
【问题讨论】: