MyTetra Share
Делитесь знаниями!
CrimeFragment.java
20.04.2017
15:48
Раздел: Android - books - AndroidProgramming2e - 9 Вывод списков и ListFragment
CrimeFragment.java
package com.bignerdranch.android.criminalintent; 
 
import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.text.Editable; 
import android.text.TextWatcher; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.Button; 
import android.widget.CheckBox; 
import android.widget.CompoundButton; 
import android.widget.EditText; 
 
public class CrimeFragment extends Fragment { 
 
    private Crime mCrime; 
    private EditText mTitleField; 
    private Button mDateButton; 
    private CheckBox mSolvedCheckbox; 
 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        mCrime = new Crime(); 
    } 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
                             Bundle savedInstanceState) { 
        View v = inflater.inflate(R.layout.fragment_crime, container, false); 
 
        mTitleField = (EditText) v.findViewById(R.id.crime_title); 
        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.setTitle(s.toString()); 
            } 
 
            @Override 
            public void afterTextChanged(Editable s) { 
 
            } 
        }); 
 
        mDateButton = (Button) v.findViewById(R.id.crime_date); 
        mDateButton.setText(mCrime.getDate().toString()); 
        mDateButton.setEnabled(false); 
 
        mSolvedCheckbox = (CheckBox) v.findViewById(R.id.crime_solved); 
        mSolvedCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 
            @Override 
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 
                mCrime.setSolved(isChecked); 
            } 
        }); 
 
        return v; 
    } 
 
 
} 

 
MyTetra Share v.0.52
Яндекс индекс цитирования