반응형
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, 1, 0, "보기");
menu.add(0, 2, 0, "추가");
menu.add(0, 3, 0, "수정");
menu.add(0, 4, 0, "삭제");
return true;
}
/**
* 메뉴버튼을 눌렀을 때 실행 되는 내용
*/
LinearLayout linear;
AutoCompleteTextView autoBooks;
public boolean onOptionsItemSelected(MenuItem item) {
linear = (LinearLayout) View.inflate(this, R.layout.books_autotext_form, null);
autoBooks = (AutoCompleteTextView) linear.findViewById(R.id.autoedit);
switch (item.getItemId()) {
case 1:
warmToastSmell("책 찾기");
// 책 이름을 선택 후 이동
autoBooks.setAdapter(new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, indexName));
new AlertDialog.Builder(this)
.setTitle("책 선택")
.setView(linear)
.setPositiveButton("보기", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
goOtherIntent("detail", autoBooks.getText().toString());
}
})
.setNegativeButton("취소", null)
.show();
return true;
case 2:
warmToastSmell("추가메뉴선택");
goOtherIntent("add", "");
return true;
case 3:
warmToastSmell("수정메뉴선택");
// 책 이름을 선택 후 이동
autoBooks.setAdapter(new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, indexName));
new AlertDialog.Builder(this)
.setTitle("수정 할 책 선택")
.setView(linear)
.setPositiveButton("수정", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
goOtherIntent("update", autoBooks.getText().toString());
}
})
.setNegativeButton("취소", null)
.show();
return true;
case 4:
warmToastSmell("삭제메뉴선택");
deleteBookDialog("");
return true;
}
return false;
}
반응형
'Android' 카테고리의 다른 글
| 자주 쓰는 메소드 : goOtherActivity, setActivity, setListener, warmToast (0) | 2013.01.30 |
|---|---|
| 토스트 Toast (0) | 2013.01.30 |
| 알림 창 Alert Dialog (0) | 2013.01.30 |
| OnItemClickListener과 OnItemLongClickListener (0) | 2013.01.30 |
| 안드로이드 색상표 (0) | 2013.01.26 |
WRITTEN BY
,




