Last active
August 29, 2015 14:26
-
-
Save basilbeltran/5d7ff9f8e0765bed0393 to your computer and use it in GitHub Desktop.
various view listeners
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { | |
View v = inflater.inflate(R.layout.fragment_m, parent, false); | |
//Button | |
mButton = (Button) v.findViewById(R.id.data_date); | |
mButton.setText(object.getDate().toString()); // mDateButton.setEnabled(false); | |
mButton.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
} | |
}); | |
//EditText | |
mEditText = (EditText) v.findViewById(R.id.object_title); | |
mEditText.setText(object.getTitle()); | |
mEditText.addTextChangedListener(new TextWatcher() { | |
public void onTextChanged(CharSequence c, int start, int before, int count) { | |
object.setTitle(c.toString()); | |
} | |
public void beforeTextChanged(CharSequence c, int start, int count, int after) {} | |
public void afterTextChanged(Editable c) {} | |
}); | |
//CheckBox | |
mCheckBox = (CheckBox)v.findViewById(R.id.object_whatever); | |
mCheckBox.setChecked(object.isWhatever()); | |
mCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { | |
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |
object.setWhatever(isChecked); } | |
}); | |
//DatePicker | |
DatePicker dpView = (DatePicker)getActivity().getLayoutInflater().inflate(R.layout.dialog_date, null); | |
mDate = (Date)getArguments().getSerializable(EXTRA_DATE); | |
Calendar cal = Calendar.getInstance(); cal.setTime(mDate); | |
dpView.init(cal.get(Calendar.YEAR), | |
cal.get(Calendar.MONTH), | |
cal.get(Calendar.DAY_OF_MONTH), | |
new DatePicker.OnDateChangedListener() { | |
public void onDateChanged(DatePicker view, int year, int month, int day) { | |
mDate = new GregorianCalendar(year, month, day).getTime(); | |
getArguments().putSerializable(EXTRA_DATE, mDate); | |
} | |
} | |
); //dpView.init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment