我有一个启动警报对话框的主要活动,在警告对话框中我有一个按钮,启动另一个活动来选择文件,在选择文件并隐藏文件选择器活动后,原始警报对话框也会隐藏用户实际上无法单击警报对话框的“确定”按钮。知道为什么会这样吗?
public class PlaceholderFragment extends Fragment {
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
MenuInflater inflater = getActivity().getMenuInflater();
if(v.getId() == R.id.zoneImageContainer)
inflater.inflate(R.menu.zone_menu, menu);
else if(v instanceof RadioButton)
{
menuRadio = (RadioButton)v;
inflater.inflate(R.menu.key_menu, menu);
}
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch(item.getItemId())
{
case R.id.editZoneMenuItem:
showEditZoneDialog();
break;
case R.id.newZoneMenuItem:
break;
case R.id.deleteZoneMenuItem:
break;
case R.id.editKeyMenuItem:
showEditKeyDialog(menuRadio);
break;
case R.id.newKeyMenuItem:
showNewKeyDialog();
break;
case R.id.deleteKeyMenuItem:
break;
}
return true;
}
public void showEditZoneDialog(){
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Zone Details:");
builder.setCancelable(false);
LayoutInflater inflater = LayoutInflater.from(getActivity());
View view = inflater.inflate(R.layout.fragment_zone_dialog, null);
builder.setView(view);
final ImageButton imageButton = (ImageButton)view.findViewById(R.id.imageButton);
final Button houseAddressButton = (Button)view.findViewById(R.id.housePickerButton);
final EditText nameText = (EditText)view.findViewById(R.id.nameEditText);
final TextView addressText = (TextView)view.findViewById(R.id.addressTextView);
.
.
.
houseAddressButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
.
.
.
}
});
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), FileDialog.class);
intent.putExtra(FileDialog.START_PATH, Environment.DIRECTORY_DCIM);
intent.putExtra(FileDialog.CAN_SELECT_DIR, false);
intent.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
intent.putExtra(FileDialog.FORMAT_FILTER,
new String[] { "png", "jpg", "jpeg", "bmp", "gif" });
getActivity().startActivityForResult(intent, 1);
}
});
// Set up the buttons
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
.
.
.
dialog.dismiss();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
}