【Android初学第29天】人生难得几回搏,此时不搏待何时。这篇文章主要讲述Android初学第29天相关的知识,希望能为你提供帮助。
android初学第29天11_ViewPaper
代码
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;
import java.util.UUID;
import static android.widget.CompoundButton.*;
public class CrimeFragment extends Fragment {private static final String ARG_CRIME_ID = "crime_id";
private Crime mCrime;
private EditText mTitleField;
private Button mDateButton;
private CheckBox mSolvedCheckbox;
public static CrimeFragment newInstance(UUID crimeId) {
Bundle args = new Bundle();
args.putSerializable(ARG_CRIME_ID, crimeId);
CrimeFragment fragment = new CrimeFragment();
fragment.setArguments(args);
return fragment;
}@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
UUID crimeId = (UUID) getArguments().getSerializable(ARG_CRIME_ID);
mCrime = CrimeLab.get(getActivity()).getCrime(crimeId);
}@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.setText(mCrime.getTitle());
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.setChecked(mCrime.isSolved());
mSolvedCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mCrime.setSolved(isChecked);
}
});
return v;
}
}
推荐阅读
- Android初学第28天
- 背水一战 Windows 10 (112) - 通知(Badge): application 的 badge 通知, secondary 的 badge 通知, 轮询服务端以更新 badge 通知(代
- 背水一战 Windows 10 (108) - 通知(Tile): application tile 基础, secondary tile 基础
- 关于安装AndroidStudio中遇见的问题
- 背水一战 Windows 10 (113) - 锁屏: 将 Application 的 Badge 通知和 Tile 通知发送到锁屏, 将 secondary tile 的 Badge 通知和 Til
- SpringMVC常见问题Error configuring application listener of class org.springframework.web.context.Context
- android -------- 打开本地浏览器或指定浏览器加载,打电话,打开第三方app
- 4.App测试与Web测试的不同
- 附录B.Spring Boot 配置文件application.properties