码迷,mamicode.com
首页 > 移动开发 > 详细

android - asynTask中打开多选alertDialog

时间:2016-11-18 00:26:53      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:opera   log   java   res   attr   title   dial   name   listener   

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

标签:opera   log   java   res   attr   title   dial   name   listener   

原文地址:http://blog.csdn.net/lan_liang/article/details/53207733

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!