@Override
    public View getView(int position, View convertView, ViewGroup parent) {

      if (convertView == null) {

        convertView = getActivity().getLayoutInflater().inflate(R.layout.list_item_crime, null);
      }
      Crime c = getItem(position);

      TextView titltTextView =
          (TextView) convertView.findViewById(R.id.crime_list_item_titleTextView);
      titltTextView.setText(c.getmTilte());
      TextView dateTextView =
          (TextView) convertView.findViewById(R.id.crime_list_item_dateTextView);
      dateTextView.setText(c.getmDate().toString());
      CheckBox solvedChexkBox =
          (CheckBox) convertView.findViewById(R.id.crime_list_item_solvedCheckBox);
      solvedChexkBox.setChecked(c.ismSolved());
      return convertView;
    }
Пример #2
0
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_crime, parent, false);

    Log.d("Mincho", mCrime.mTitle == null ? "Title is null" : "Title is not null");
    // Log.d("Mincho", mCrime.mDate == null ? "Date is null" : "Date is not null");
    // Log.d("Mincho", mCrime.mId == null ? "Id is null" : "Id is not null");
    // Log.d("Mincho", mCrime.mSolved == null ? "solved is null" : "solved is not null");
    mTitleField = (EditText) v.findViewById(R.id.crime_title);
    mTitleField.setText(mCrime.getmTitle());
    mTitleField.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            mCrime.setmTitle(s.toString());
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });
    // android.text.format.DateFormat.format("yyy-mm-dd", new java.util.Date());
    mDateButton = (Button) v.findViewById(R.id.crime_date);
    mDateButton.setText(mCrime.getmDate().toString());
    mDateButton.setEnabled(false);

    mSolvedCheckBox = (CheckBox) v.findViewById(R.id.crime_solved);
    mSolvedCheckBox.setChecked(mCrime.ismSolved());
    mSolvedCheckBox.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mCrime.setmSolved(isChecked);
          }
        });
    return v;
  }