private Dialog modifyNickName() {
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(
R.layout.alert_change_nickname, null);
return new AlertDialog.Builder(My.this).setIcon(
R.drawable.alert_dialog_icon).setTitle(
getString(R.string.change_nickname)).setView(textEntryView)
.setPositiveButton(R.string.alert_dialog_setting,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
EditText editNickNameText = (EditText) textEntryView
.findViewById(R.id.nickname);
String nickName = editNickNameText.getText()
.toString();
Toast.makeText(
My.this,
nickName,
Toast.LENGTH_SHORT).show();
Field field;
try {
field = dialog.getClass()
.getSuperclass().getDeclaredField(
"mShowing");
field.setAccessible(true);
if(nickName == null || nickName.equals(""))
{
field.set(dialog, false);
}else
{
field.set(dialog, true);
}
dialog.dismiss();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}).setNegativeButton(R.string.alert_dialog_cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
Field field;
try {
field = dialog.getClass()
.getSuperclass().getDeclaredField(
"mShowing");
field.setAccessible(true);
field.set(dialog, true);
dialog.dismiss();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}).create();
}