| 216 | |
| 217 | |
| 218 | public void AddToLog( final String logMessage ) { |
| 219 | final ListView lv = ((ListView)findViewById(R.id.listView1)); |
| 220 | lv.post(new Runnable() { |
| 221 | public void run() { |
| 222 | //final boolean bAutoscroll = lv.getLastVisiblePosition() >= mAdapter.getCount() - 1 ? true : false; |
| 223 | |
| 224 | mLogList.add(logMessage); |
| 225 | while( mLogList.size() > 100 ) // only allow 100 messages in the list, otherwise it might slow the GUI down |
| 226 | { |
| 227 | mLogList.remove(0); |
| 228 | } |
| 229 | mAdapter.notifyDataSetChanged(); |
| 230 | |
| 231 | |
| 232 | // Autoscroll detection is dodgy |
| 233 | //if( bAutoscroll ) |
| 234 | { |
| 235 | lv.setSelection(mAdapter.getCount() - 1); |
| 236 | } |
| 237 | } |
| 238 | }); |
| 239 | } |
| 240 | |
| 241 | |
| 242 | |