Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. @Override
  2. public void bindView(View view, Context context, final Cursor cursor) {
  3.  
  4. // id starts from 1. So that's why I add 1 to the current cursor's position.
  5. final int id = cursor.getPosition() + 1;
  6. final Alarm alarm = dbHelper.getAlarm(id);
  7.  
  8. TextView tvSetAlarmTime = (TextView) view.findViewById(R.id.tvSetAlarmTime);
  9. String strAlarmTime = alarm.getAlarmTimeString();
  10. tvSetAlarmTime.setTextColor(ContextCompat.getColor(context, R.color.dark_grey));
  11. tvSetAlarmTime.setText(strAlarmTime);
  12.  
  13. Switch switchAlarmOnOff = (Switch) view.findViewById(R.id.switchAlarmOnOff);
  14. boolean active = alarm.isAlarmActive();
  15. switchAlarmOnOff.setChecked(active);
  16.  
  17. switchAlarmOnOff.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  18. @Override
  19. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  20.  
  21. }
  22. });
  23.  
  24. ...
  25.  
  26. ImageView ivDelete = (ImageView) view.findViewById(R.id.ivDelete);
  27. ivDelete.setOnClickListener(new View.OnClickListener() {
  28. @Override
  29. public void onClick(View v) {
  30. dbHelper.deleteAlarm(id);
  31. cursor.requery();
  32. notifyDataSetChanged();
  33. }
  34. });
  35.  
  36. 01-19 19:31:46.298 19339-19339/com.marshall.alarm E/AndroidRuntime: FATAL EXCEPTION: main
  37. Process: com.marshall.alarm, PID: 19339
  38. java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
  39. at com.marshall.alarm.ui.AlarmListFragment$AlarmListAdapter.bindView(AlarmListFragment.java:192)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement