My app uses a gridview to display a list of values (imagine a calendar). I have a button that forces the list of values to be recalculated.
When the apps starts the grid view is correctly displayed and individual cells can be selected and the correct position is displayed (ie position 0 is at the top left and the last position is at the bottom right). When the button is clicked, the list is recalculated, invalidateview is called to reload the view, all is well except when a cell is selected the positions are reversed: ie. position 0 is now at the bottom right and the last position is at the top left. If the button is clicked again, the position reverts to the original. Basically, for even clicks the position is correct and for odd number the position is flipped. This is the code I use is below, same as the code in the gridview demo with the addition of the onsetclicklistener Is this the behavior of a list? Should I keep track of hoe many times the list is updated and recalculate the correct position index? Thanks public class MyAdapter extends BaseAdapter { private Context context; public MyAdapter(Context context) { this.context = context; } public int getCount() { return 48; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } public View getView(final int position, View convertView, ViewGroup parent) { TextView tv; if (convertView == null) { tv = new TextView(context); tv.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Log.d("onClick","position "+position); } }); } else { tv = (TextView) convertView; } tv.setText(dateList[position]); return tv; } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---