[android-developers] Re: Unable to Uncheck CheckBox on ListView

2011-08-26 Thread Zsolt Vasvari
Obviously, given just that code, it's impossible to know to what's
wrong, but initialized checkedItems in getView() looks very incorrect
to me.

On Aug 26, 3:48 pm, RobinDroid librain.ro...@gmail.com wrote:
 Dear All,
 I have problem on unchecking the checkbox when a menu is fired.?
 I am using a baseAdapter where i have a getView() method as such:
 ---­---­-
 public View getView(final int position, View view, ViewGroup parent) {
                 final ViewHolder viewHolder;
                 if (view == null) {
                         viewHolder = new ViewHolder();
                         view = layoutInfalter.inflate(R.layout.inbox_row, 
 null);
                         viewHolder.checkBox = (CheckBox)
 view    .findViewById(R.id.inboxCheckId);
                         if (INBOX_VIEW_MODE == -1) {
                                 viewHolder.checkBox.setVisibility(View.GONE);
                         } else {
                                 InboxEmailAdapter.setInboxViewMode(1);
                                 
 viewHolder.checkBox.setVisibility(View.VISIBLE);
                                 checkedItems = new ArrayListInteger();
                                 
 viewHolder.checkBox.setOnCheckedChangeListener(new
 OnCheckedChangeListener() {

                                         @Override
                                         public void 
 onCheckedChanged(CompoundButton buttonView, boolean
 isChecked) {
                                                 if(isChecked){

 viewHolder.checkBox.setId(inboxEmailList.get(position).getId());
                                                         
 checkedItems.add(viewHolder.checkBox.getId());
                                                 }

                                         }
                                 });
                         }
                         viewHolder.emailFrom = (TextView)
 view.findViewById(R.id.inboxFrom);
                         viewHolder.emailSubject = (TextView)
 view.findViewById(R.id.inboxSubject);
                         view.setTag(viewHolder);

                 } else {
                         viewHolder = (ViewHolder) view.getTag();
                 }

 viewHolder.emailFrom.setText(inboxEmailList.get(position).getFrom());

 viewHolder.emailSubject.setText(inboxEmailList.get(position).getSubject());

                 return view;
         }
 ---­---­-
 On my activity:

 I have a listView populated with checkbox?
 I select checkbox, it is being selected.
 On my Menu i have cancel button which on click should uncheck the
 selected checkbox?
 I am not being able to perform this?

 Any helps would really help me

-- 
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


[android-developers] Re: Unable to Uncheck CheckBox on ListView

2011-08-26 Thread RobinDroid
Why is it so? for me it's working, well my view has slide modification
as i need to hide intially the checkbox and all and as to that reason
my view as above.
Can you suggest me what seems incorrect in the getView() ?

On Aug 26, 1:11 pm, Zsolt Vasvari zvasv...@gmail.com wrote:
 Obviously, given just that code, it's impossible to know to what's
 wrong, but initialized checkedItems in getView() looks very incorrect
 to me.

 On Aug 26, 3:48 pm, RobinDroid librain.ro...@gmail.com wrote:







  Dear All,
  I have problem on unchecking the checkbox when a menu is fired.?
  I am using a baseAdapter where i have a getView() method as such:
  --- 
  ­-- 
  -­-
  public View getView(final int position, View view, ViewGroup parent) {
                  final ViewHolder viewHolder;
                  if (view == null) {
                          viewHolder = new ViewHolder();
                          view = layoutInfalter.inflate(R.layout.inbox_row, 
  null);
                          viewHolder.checkBox = (CheckBox)
  view    .findViewById(R.id.inboxCheckId);
                          if (INBOX_VIEW_MODE == -1) {
                                  
  viewHolder.checkBox.setVisibility(View.GONE);
                          } else {
                                  InboxEmailAdapter.setInboxViewMode(1);
                                  
  viewHolder.checkBox.setVisibility(View.VISIBLE);
                                  checkedItems = new ArrayListInteger();
                                  
  viewHolder.checkBox.setOnCheckedChangeListener(new
  OnCheckedChangeListener() {

                                          @Override
                                          public void 
  onCheckedChanged(CompoundButton buttonView, boolean
  isChecked) {
                                                  if(isChecked){

  viewHolder.checkBox.setId(inboxEmailList.get(position).getId());
                                                          
  checkedItems.add(viewHolder.checkBox.getId());
                                                  }

                                          }
                                  });
                          }
                          viewHolder.emailFrom = (TextView)
  view.findViewById(R.id.inboxFrom);
                          viewHolder.emailSubject = (TextView)
  view.findViewById(R.id.inboxSubject);
                          view.setTag(viewHolder);

                  } else {
                          viewHolder = (ViewHolder) view.getTag();
                  }

  viewHolder.emailFrom.setText(inboxEmailList.get(position).getFrom());

  viewHolder.emailSubject.setText(inboxEmailList.get(position).getSubject());

                  return view;
          }
  --- 
  ­-- 
  -­-
  On my activity:

  I have a listView populated with checkbox?
  I select checkbox, it is being selected.
  On my Menu i have cancel button which on click should uncheck the
  selected checkbox?
  I am not being able to perform this?

  Any helps would really help me

-- 
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