Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. public class AdapterContacts extends BaseAdapter implements OnClickListener {
  2.  
  3. ToggleButton btnIsSending;
  4. .
  5. .
  6. .
  7.  
  8. public View getView(int position, View convertView, ViewGroup viewGroup) {
  9. Contact entry = contactsList.get(position);
  10. if (convertView == null) {
  11. LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  12. convertView = inflater.inflate(R.layout.contact_row, null);
  13. }
  14. .
  15. .
  16. .
  17. // isSending button
  18. btnIsSending = (ToggleButton) convertView.findViewById(R.id.btnIsSending);
  19. btnIsSending.setFocusableInTouchMode(false);
  20. btnIsSending.setFocusable(false);
  21. btnIsSending.setOnClickListener(this);
  22. btnIsSending.setTag(entry);
  23.  
  24. return convertView;
  25. }
  26.  
  27. public void onClick(View view) {
  28. final Contact entry = (Contact) view.getTag();
  29. Log.d(TAG, "entry " + entry.getPhoneNr());
  30.  
  31. LookalizeData lookData = (LookalizeApp.getContext()).lookalizeData;
  32. // Toggle send button
  33. if( view.getId() == btnIsSending.getId()){
  34. if(btnIsSending.isChecked())
  35. ...
  36. else
  37. ...
  38. }
  39.  
  40. ListView lv = ((ListActivity)context).getListView();
  41. // Containing all check states
  42. SparseBooleanArray sba = lv.getCheckedItemPositions();
  43.  
  44. btnIsSending = (ToggleButton) convertView.findViewById(R.id.btnIsSending);
  45. btnIsSending.setFocusableInTouchMode(false);
  46. btnIsSending.setFocusable(false);
  47. btnIsSending.setTag(entry);
  48.  
  49. btnIsSending.setChecked(false);
  50.  
  51. // Cursor is passed as an argument.
  52. if(sba != null)
  53. if(sba.get(cursor.getPosition()))
  54. btnIsSending.setChecked(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement