Does any changes in the child of listview is reflected in its adaptor.

by Manoj » Thu, 21 Jan 2010 17:10:28 GMT


Sponsored Links
 Hi can anybody tell me exactly how can i get the the exact status of
the listview items.(I have used checkbox as the listview item)



Does any changes in the child of listview is reflected in its adaptor.

by Nikhil Agarwal » Thu, 21 Jan 2010 19:36:55 GMT


 I suppose you mean that how can we extract which items are checked.
That can be done using:-
SparseBooleanArray checkedItems = getListView().getCheckedItemPositions
();
You can check each item's state by using its position. So for the 0th
position, use checkedItems.get(0) and check if it is true or false.



> the listview items.(I have used checkbox as the listview item)


Sponsored Links


Does any changes in the child of listview is reflected in its adaptor.

by Manoj » Thu, 21 Jan 2010 20:21:42 GMT


 Mr. Nikhil can you send me the code to use this method .....

Thanks in advance



Other Threads

1. does android provides API for muiti tap?

How to achieve multi tap for 3x4 virtual keyboard?

Regards
Pradeep
--~--~---------~--~----~------------~-------~--~----~

2. GridView and List

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;
                        }
            }
--~--~---------~--~----~------------~-------~--~----~

3. Book suggestion

4. loading PNG data to WebView

5. Accessing SharedPreferences in Services and non-Activities

6. View background question

7. Accessing SharedPreferences in Services and non-Activities