p.s. - i've looked at the google developers site, but could not make sense of it. Where do i need to call all this stuff
- Code: Select all
public class SettingList extends ListActivity implements OnItemClickListener {
static final String[] OPTIONS = new String[] {"Alarm Name", "Set Time", "Repeat", "Sound" };
ArrayAdapter<String> options;
static final int DIALOG_TIME_ID = 1;
private int mHour;
private int mMinute;
public SharedPreferences.Editor prefsEditor;
public SharedPreferences myPrefs;
final String items[] = {"item1","item2","item3"};
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
prefsEditor = myPrefs.edit();
//Sets up the list view
options = new ArrayAdapter<String>(this, R.layout.list_item, OPTIONS);
setListAdapter(options);
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(this);
}
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
int pos = position;
switch(pos)
{
case 0:
break;
case 1:
showDialog(DIALOG_TIME_ID);
case 2:
case 3:
}
}
protected Dialog onCreateDialog(int id) {
Dialog dialog;
switch(id) {
case DIALOG_TIME_ID:
return new TimePickerDialog(this, mTimeSetListener, mHour, mMinute, true); //(Context context, TimePickerDialog.OnTimeSetListener callBack, int hourOfDay, int minute, boolean is24HourView)
default:
dialog = null;
}
return dialog;
}
// the callback received when the user "sets" the time in the dialog
private TimePickerDialog.OnTimeSetListener mTimeSetListener = new TimePickerDialog.OnTimeSetListener()
{
public void onTimeSet(TimePicker view, int hourOfDay, int minute)
{
mHour = hourOfDay;
mMinute = minute;
prefsEditor.putInt("hour", mHour);
prefsEditor.putInt("minute", mMinute);
prefsEditor.commit();
}
};
}


