1
我想要一個項目列表,當被點擊時會打開另一個項目列表。而不像項目的子菜單。這是因爲我的第一份名單變得越來越長,我想將它們組合成一個子菜單。如預期AlertDialog.Builder setItems與另一個列表
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, final int position, long id) {
final CharSequence[] items = {"Gallery Image Menu", "View pattern", "Delete pattern", "Locate pattern in list view", "Row Counter (with pattern)", "Share Pattern", "Share Image", "Cancel"};
AlertDialog.Builder builder = new AlertDialog.Builder(grid.this);
builder.setTitle(selectedimage);
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
if (item == 0){
//first menu 1st item
dialog.dismiss();
final CharSequence[] items2 = {"Rotate image 180"+"\u00B0", "Rotate image 90"+"\u00B0", "Add image from pattern", "Add image from file", "Add image from camera", "Remove image", "Cancel"};
final AlertDialog.Builder builder2 = new AlertDialog.Builder(grid.this);
builder2.setTitle(selectedimage);
builder2.setItems(items2, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog2, int item) {
if(item == 0){
//2nd menu, 1st item
dialog2.dismiss();
//do something
return;
}
if(item == 1){
dialog2.dismiss();
//2nd menu, 2nd item
//do something else
return;
}
AlertDialog alert2 = builder2.create();
alert2.show();
}
});
}
if (item == 1){
//first menu 2nd item
}
if(item == 2){
//1st menu, 3rd item
}
if(item == 3){
}
//..... etc
}
});
AlertDialog alert = builder.create();
alert.show();
}
});//gridView.setOnItemClickListener
第一建設者顯示方式,但是當我選擇,我想開第二個製造商的第一建設者關閉並返回到活動的第一個選項。
在調試模式下,第二個構建器代碼被讀取,就好像它要顯示但是兩者都關閉一樣。
也許你不能這樣做?
任何想法?
啊!感謝您指出了這一點。 – Mark