Valten1992
Newbie
So after two days of fruitless bashing my head against a desk, I am at my wits end with this android app I'm making. Basically, it populates a listview, each row containing 3 values that will be updated at a specified interval. The values are blank on startup but are initialised after the first run through the code.
However, every other time the listview wont rewrite itself! Logcat tells me the updated values are being passed in but the adapter won't update. Can anyone point out the no doubt obvious mistake I'm making.
The method doit()
However, every other time the listview wont rewrite itself! Logcat tells me the updated values are being passed in but the adapter won't update. Can anyone point out the no doubt obvious mistake I'm making.
Code:
adapter = new snmpAdapterView(this, parsedObjects);
setListAdapter(adapter);
Timer tim = new Timer();
tim.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
doit();
Log.e("NOTE", "done");
Log.e("empty?", adapter.isEmpty()+"");
}
}, 0, 10000);
Code:
public void doit() {
Log.e("","Initialised");
ExecutorService pool = Executors.newCachedThreadPool();
for (int i = 0; i < parsedObjects.size(); i++)// submit threads equal to
// // number of objects
{
snmpObject s = parsedObjects.get(i);
pool.submit(s); // run the i'th object instance
}
pool.shutdown();
try {
pool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {
}
handler.post(new Runnable() {
public void run() {
Log.e("update", "true");
adapter.setList(parsedObjects);
adapter.notifyDataSetChanged();
}
});
}