【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(); } }
推荐阅读
- Android -- 打开时隐藏软键盘
- Android消息的提示,Toast吐司方式
- 我的Android第三章(Android的组件介绍)
- Android端上传图片到后台,存储到数据库中 详细代码
- [Android Pro]Android TypedValue.applyDimension()的用法
- Android中土司(Toast)的使用
- 如何从给定的中序和先序遍历中打印后序遍历()
- JavaScript基本语法介绍和用法指南
- 算法设计(求将给定重量装进袋子的最低成本)