I'm trying to make a ListActivity that gets the data to show from a website but it seems that something goes wrong and the list no longer gets updated (take a look at the code and you'll understand what I mean). Here is the code you can use to recreate this "error":
Using java Syntax Highlighting
- public class ListTest extends ListActivity {
- private List<String> mItems = new ArrayList<String>();
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setListAdapter(new ArrayAdapter<String>(this,
- android.R.layout.simple_list_item_1, mItems));
- Thread thread = new Thread() {
- public void run() {
- try {
- mItems.add("This item shows up");
- Log.d("Debug", mItems.get(mItems.size()-1));
- try{
- DefaultHttpClient client = new DefaultHttpClient();
- HttpGet get = new HttpGet("http://google.com");
- HttpResponse response = client.execute(get);
- }
- catch(Exception e){};
- mItems.add("This one doesn't");
- Log.d("Debug", mItems.get(mItems.size()-1));
- } catch (Exception e) {
- }
- }
- };
- thread.start();
- }
- }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
So basically, what this does is show a list with only 1 item, when there should be 2.
This is what LogCat shows:
12-04 20:21:33.582: DEBUG/Debug(1115): This item shows up
12-04 20:21:34.641: INFO/ActivityManager(50): Displayed activity net.funmi.android/.ShowMoviesInterm: 1723 ms
12-04 20:21:34.842: DEBUG/dalvikvm(1115): GC freed 2981 objects / 186856 bytes in 75ms
12-04 20:21:35.321: DEBUG/dalvikvm(1115): GC freed 628 objects / 52344 bytes in 57ms
12-04 20:21:38.711: DEBUG/dalvikvm(1115): GC freed 1748 objects / 297720 bytes in 72ms
12-04 20:21:39.271: DEBUG/Debug(1115): This one doesn't
I also tried using a handler and the same thing happens...
mItems adds the second item as it should but somehow, the ArrayAdapter's getView() never gets called ...
Is there a bug in my code or is there a bug on Google's side?
Thank you!

