Add new items to top of list view on Android?

后端 未结 7 1528
梦谈多话
梦谈多话 2020-11-30 03:19

Android has the transcript mode to allow to automatically scroll a list view to the bottom when new data is added to the adapter.

Can this be somehow reversed so tha

7条回答
  •  醉酒成梦
    2020-11-30 03:44

    This resolves the problem:

    ...
    ListView lv;
    ArrayAdapter adapter;
    ArrayList aList;
    ...
            lv = (ListView) findViewById(R.id.mylist);
    
            aList = new ArrayList();
            adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_item, aList);
            lv.setAdapter(aAdapter);
            ...
            adapter.insert ("Some Text 1", 0);
            adapter.insert ("Some Text 2", 0);
            adapter.insert ("Some Text 3", 0);
            ...
    

提交回复
热议问题