1. Download our Official Android App: Forums for Android!

Apps BaseAdapter problem

Discussion in 'Android Development' started by zhzhd82, Oct 22, 2010.

  1. zhzhd82

    zhzhd82 Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    2
    Joined:
    Apr 15, 2010

    Apr 15, 2010
    2
    1
    6
    Hi all
    I custom an adapter that extends BaseAdapter.In the getView() method I use the code Log.d("test",Integer.toString(position)); to output the position. The problem now is every time when the adapter notifyDataSetChanged() method is invoked the position first is 0 1 2 3 4(5 items in the screen) and then the displayed ListView item index in the screen.Why? Thank you very much!
     

    Advertisement

    vladimirov likes this.
  2. vladimirov

    vladimirov Newbie
    Rank:
    None
    Points:
    16
    Posts:
    17
    Joined:
    Apr 26, 2010

    Apr 26, 2010
    17
    2
    16
    Because of listview optimizes work of elements creation.

    Firstly listview creates a maximum needed count of elements and then reuse them. For each next element, in method getView you will recieve already created view as parameter convertedView.

    So If this parameter not null you should use it as already created view, fill in it your data and return it as new vew.
     

Share This Page

Loading...