首页 > 代码库 > 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 - asynTask中打开多选alertDialog
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。