android - asynTask中打开多选alertDialog

【android - asynTask中打开多选alertDialog】学向勤中得,萤窗万卷书。这篇文章主要讲述android - asynTask中打开多选alertDialog相关的知识,希望能为你提供帮助。

private class xxxAsyncTask extends AsyncTask< String, Void, Boolean> { ... AlertDialog.Builder alertBuilder ; ... @Override protected void onPreExecute() { ... alertBuilder = new AlertDialog.Builder(ResultActivity.this); ... }@Override protected Boolean doInBackground(String... params) { ... }@Override protected void onPostExecute(Boolean result) { super.onPostExecute(result); alertBuilder.setTitle(" Choose Attraction" ); ... //prepare data String[] arr = new String[operationNames.size()]; operationNames.toArray(arr); alertBuilder.setItems(arr, new DialogInterface.OnClickListener() {@Override public void onClick(DialogInterface dialog, int index) { try{ // if select index == x , do something //// keep in mind that java is not allowed to block the UI thread doing network post //// have to wrap this inside one async task, e.g: new xxxAsync().execute(usageUrl, json); ... } catch (Exception ex){} finally { dialog.dismiss(); } } }); alertBuilder.create().show(); } }




    推荐阅读