private void setServerIp() { final EditText edittext = new EditText(this); edittext.setText( getSharedPreferences("aplicaint_info", 0).getString(ResourceData.SETTING_SERVERIP, "")); DialogUtil.showViewDialog( this, "设置服务器IP地址:", edittext, new DialogUtil.Handler() { @Override public void todo(DialogInterface dialog, int which) { if (!edittext.getText().toString().trim().equals("")) { if (checkString(edittext.getText().toString().trim())) { WriteSharedPreferences( ResourceData.SETTING_SERVERIP, edittext.getText().toString()); HttpUtil.BASE_URL = edittext.getText().toString(); dolater(); } else { DialogUtil.showAffirmDialog( CampusdishclientActivity.this, "错误", "IP地址格式输入不正确!应为:192.168.1.1", new DialogUtil.Handler() { @Override public void todo(DialogInterface dialog, int which) { setServerIp(); } }, new DialogUtil.Handler() { @Override public void todo(DialogInterface dialog, int which) {} }); } } else { DialogUtil.showAffirmDialog( CampusdishclientActivity.this, "错误", "ip地址不能为空", new DialogUtil.Handler() { @Override public void todo(DialogInterface dialog, int which) { setServerIp(); } }, new DialogUtil.Handler() { @Override public void todo(DialogInterface dialog, int which) {} }); } } }, new DialogUtil.Handler() { @Override public void todo(DialogInterface dialog, int which) {} }); }
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { if (event.getAction() == KeyEvent.ACTION_UP && isBackKeyDown) { DialogUtil.showAffirmDialog( this, "确认", "确认退出?", true, new DialogUtil.Handler() { public void todo(DialogInterface dialog, int witch) { CampusdishclientActivity.this.finish(); System.exit(0); } }); isBackKeyDown = false; return true; } else if (event.getAction() == KeyEvent.ACTION_DOWN) { isBackKeyDown = true; return true; } } return super.dispatchKeyEvent(event); }