@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.settings); this.setTitle(R.string.setting); sp = PreferenceManager.getDefaultSharedPreferences(this); edit = sp.edit(); Button widgettheme = (Button) findViewById(R.id.widgettheme); Button settime = (Button) findViewById(R.id.settime); Button save = (Button) findViewById(R.id.set_save); nc = (CheckBox) findViewById(R.id.nightcheck); rs = (CheckBox) findViewById(R.id.ringswitch); widgettheme.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View Button) { AlertDialog.Builder ad = new AlertDialog.Builder(Settings.this) .setTitle("选择颜色?") .setItems( color, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { edit.putInt("widgetTextColor", colori[p2]); edit.commit(); } }); ad.show(); } }); settime.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View Button) { Intent set = new Intent(Settings.this, Settime.class); startActivity(set); return; } }); save.setOnClickListener( new View.OnClickListener() { public void onClick(View Button) { save(); return; } }); nc.setChecked(sp.getBoolean("nightmode", false)); if (sp.getBoolean("timewrong", false) == true) { rs.setChecked(false); rs.setClickable(false); } }
private void setIsDone() { CheckBox isDone = getIsDoneComponent(); isDone.setChecked(task.getBoolean(TaskAdapter.IS_DONE, false)); }