Ejemplo n.º 1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_to_do, container, false);

    titleField = (EditText) v.findViewById(R.id.title_field);
    titleField.addTextChangedListener(new TitleListener());

    dateButton = (Button) v.findViewById(R.id.due_date_button);
    dateButton.setOnClickListener(new OnDateButtonClick());

    prioritySpinner = (Spinner) v.findViewById(R.id.priority_spinner);
    prioritySpinner.setOnItemSelectedListener(new PriorityListener());

    completeCheckbox = (CheckBox) v.findViewById(R.id.complete_checkbox);
    completeCheckbox.setOnClickListener(new CompleteCheckListener());

    // set view components to display detail
    titleField.setText(toDo.getTitle());
    dateButton.setText(toDo.getDueDate().toString());
    prioritySpinner.setSelection(toDo.getPriority());
    completeCheckbox.setChecked(toDo.isComplete());

    return v;
  }
Ejemplo n.º 2
0
 public void onChangeToDoState(View view) {
   int index = (int) view.getTag();
   ToDo toDo = listFragment.repository.getItem(index);
   toDo.setDone(!toDo.isDone());
   listFragment.repository.update(index, toDo);
   if (isTwoPane && listFragment.activatedPosition == index) {
     onItemSelected(toDo);
   }
 }
Ejemplo n.º 3
0
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   if (v.getId() == listFragment.getListView().getId()) {
     AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
     ToDo toDo = listFragment.repository.getItem(info.position);
     getMenuInflater().inflate(R.menu.menu_item_context, menu);
     menu.setHeaderTitle(toDo.getTitle());
   }
 }
Ejemplo n.º 4
0
 private static void reflectionUsingAnnotation() {
   Class<AnnotationApp> annotationApp = AnnotationApp.class;
   for (Method method : annotationApp.getMethods()) {
     ToDo annotation = (ToDo) method.getAnnotation(ToDo.class);
     if (annotation != null) {
       System.out.println(
           " Method Name : "
               + method.getName()
               + " | Priority : "
               + annotation.priority()
               + " | Status : "
               + annotation.status());
     }
   }
 }