我正在打开一个自定义对话框"点击忘记密码"按钮。在自定义对话框中单击“发送”按钮,我正在检索密码,但是我收到了此异常。这是我的代码:
protected Dialog onCreateDialog(int id) {
AlertDialog dialogDetails = null;
switch (id) {
case DIALOG_LOGIN:
LayoutInflater inflater = LayoutInflater.from(this);
View dialogview = inflater.inflate(R.layout.custom_dialog, null);
AlertDialog.Builder dialogbuilder = new AlertDialog.Builder(this);
dialogbuilder.setView(dialogview);
dialogDetails = dialogbuilder.create();
break;
}
return dialogDetails;
}
@Override
@Deprecated
protected void onPrepareDialog(int id, Dialog dialog) {
switch (id) {
case DIALOG_LOGIN:
final AlertDialog alertDialog = (AlertDialog) dialog;
Button loginbutton = (Button) alertDialog
.findViewById(R.id.btn_login);
Button cancelbutton = (Button) alertDialog
.findViewById(R.id.btn_cancel);
final EditText emailid = (EditText) alertDialog
.findViewById(R.id.dialog_txt_name);
loginbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new ForgotPassword().execute();
}
});
cancelbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
alertDialog.dismiss();
}
});
break;
// TODO Auto-generated method stub
}
}
class ForgotPassword extends AsyncTask<String, Void, Void> {
// Required initialization
private final HttpClient client = new DefaultHttpClient();
private String Content;
private String Error = null;
private ProgressDialog dialog = new ProgressDialog(PtLogin.this);
String data = "";
EditText etuser_Name = (EditText) findViewById(R.id.dialog_txt_name);
protected void onPreExecute() {
dialog.setMessage("Please wait..");
dialog.show();
}
// Call after onPreExecute method
protected Void doInBackground(String... urls) {
//http://69.73.184.155/~isoft/doctorApp/web_serv/
//forget_pass.php?access_token=testermanishrahul234142test&userName=%@
List<NameValuePair> nameValuePairs=new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("access_token","testermanishrahul234142test"));
nameValuePairs.add(new BasicNameValuePair("userName",etuser_Name.getText().toString()));
Content=new ServiceHandler().makeServiceCall(AppConstant.FORGOT_PASSWORD_URL, 2, nameValuePairs);
return null;
}
protected void onPostExecute(Void unused) {
// NOTE: You can call UI Element here.
// Close progress dialog
dialog.dismiss();
/****************** Start Parse Response JSON Data *************/
String OutputData = "";
JSONObject jsonResponse;
try {
/******
* Creates a new JSONObject with name/value mappings from the
* JSON string.
********/
jsonResponse = new JSONObject(Content);
System.out.println("=====response" + jsonResponse.toString());
/*****
* Returns the value mapped by name if it exists and is a
* JSONArray.
***/
/******* Returns null otherwise. *******/
JSONObject jsonMainNode = jsonResponse
.getJSONObject("document");
JSONObject response = jsonMainNode.getJSONObject("response");
String status = response.getString("status");
if (status != null && status.equalsIgnoreCase("1")) {
}
String message = response.getString("message");
Toast.makeText(getApplicationContext(),
"" + status + ":" + message, Toast.LENGTH_SHORT).show();
// /*********** Process each JSON Node ************/
} catch (JSONException e) {
e.printStackTrace();
}
}
}
..........我的logcat在这里............
04-01 12:30:02.601: E/WindowManager(30294): android.view.WindowLeaked: Activity com.example.doctorpocket.PtLogin has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{42e815e0 V.E..... R......D 0,0-684,192} that was originally added here
04-01 12:30:02.601: E/WindowManager(30294): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:425)
04-01 12:30:02.601: E/WindowManager(30294): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:250)
04-01 12:30:02.601: E/WindowManager(30294): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
04-01 12:30:02.601: E/WindowManager(30294): at android.app.Dialog.show(Dialog.java:297)
04-01 12:30:02.601: E/WindowManager(30294): at com.example.doctorpocket.PtLogin$ForgotPassword.onPreExecute(PtLogin.java:359)
04-01 12:30:02.601: E/WindowManager(30294): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
04-01 12:30:02.601: E/WindowManager(30294): at android.os.AsyncTask.execute(AsyncTask.java:535)
04-01 12:30:02.601: E/WindowManager(30294): at com.example.doctorpocket.PtLogin$1.onClick(PtLogin.java:317)
04-01 12:30:02.601: E/WindowManager(30294): at android.view.View.performClick(View.java:4472)
04-01 12:30:02.601: E/WindowManager(30294): at android.view.View$PerformClick.run(View.java:18779)
04-01 12:30:02.601: E/WindowManager(30294): at android.os.Handler.handleCallback(Handler.java:808)
04-01 12:30:02.601: E/WindowManager(30294): at android.os.Handler.dispatchMessage(Handler.java:103)
04-01 12:30:02.601: E/WindowManager(30294): at android.os.Looper.loop(Looper.java:193)
04-01 12:30:02.601: E/WindowManager(30294): at android.app.ActivityThread.main(ActivityThread.java:5333)
04-01 12:30:02.601: E/WindowManager(30294): at java.lang.reflect.Method.invokeNative(Native Method)
04-01 12:30:02.601: E/WindowManager(30294): at java.lang.reflect.Method.invoke(Method.java:515)
04-01 12:30:02.601: E/WindowManager(30294): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
04-01 12:30:02.601: E/WindowManager(30294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
04-01 12:30:02.601: E/WindowManager(30294): at `enter code here`dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:0)
将您的活动用于AlertDialog。
Array
(
[A] => Array
(
[A] => Array
(
[01] => Array
(
[01] => Array
(
[0] => 01
[1] => 02
)
[02] => Array
(
[0] => 01
[1] => 02
)
[03] => Array
(
[0] => 01
)
)
)
)
)