0
有誇大某個條件的真正的Android菜單的可能性,我希望如此,這是可能的,如果是的話這裏是我的錯誤代碼,什麼是我的病情錯誤檢查條件檢查
並且其中應條件檢查代碼必須放置,以便從充氣在conition檢查失敗,其中線
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.bar, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("Pick An Image")
.setMessage("Please select Image One or Image Two:")
.setCancelable(false)
.setPositiveButton("IMAGE 1", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface Dialog,int id){
//image.setImageResource(R.drawable.image1);
}
})
.setNeutralButton("IMAGE 3",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface Dialog,int id){
//image.setImageResource(R.drawable.icon);
}
})
.setNegativeButton("Image 2", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int id){
//image.setImageResource(R.drawable.image2);
}
});
Spinner spinner1=(Spinner)findViewById(R.id.spinner1);
Spinner spinner2=(Spinner)findViewById(R.id.spinner2);
int dim1=spinner1.getSelectedItemPosition();
int dim2=spinner2.getSelectedItemPosition();
if(dim1==dim2)
{
Toast.makeText(null, "your source and destination are same", Toast.LENGTH_SHORT).show();
}
else
{
switch(item.getItemId()){
case R.id.buttonone:
builder.show();
return true;
case R.id.buttontwo:
builder.show();
return true;
case R.id.buttonthree:
builder.show();
return true;
case R.id.buttonfour:
builder.show();
return true;
case R.id.buttonfive:
builder.show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
return super.onOptionsItemSelected(item);
}
i執行條件檢查是否可以從充氣停止菜單狀態期間失敗的情況下,停止該菜單。
感謝您的回答,幫助我。 – 2014-08-21 04:43:58