今日寫了個如題目的簡單功能,結果列表不顯示app
無奈重寫了一次代碼發現setMessage和setSingleChoiceItems不能同時使用。ide
正確的以下:ui
private void mobilePhone(){ AlertDialog.Builder builder = new AlertDialog.Builder(HomePageChildrenActivity.this.getParent()); if(children_Data.schoolbean.schType.equals("K")){//幼兒園 List<FriendsBean> teacherlist = new ArrayList<FriendsBean>(); for(int i=0;i<children_Data.friends.size();i++){ if(children_Data.friends.get(i).getUsertype().equals("T")){ teacherlist.add(children_Data.friends.get(i)); } } String[] teachers = new String[teacherlist.size()] ; for(int i=0;i<teacherlist.size();i++){ teachers[i]=teacherlist.get(i).getUserneme(); } ButtonOnClick buttonOnClick = new ButtonOnClick(0,teacherlist); builder.setTitle("請選擇教師"); builder.setSingleChoiceItems(teachers, 0,buttonOnClick); builder.setPositiveButton("確認",buttonOnClick); builder.setNegativeButton("取消",buttonOnClick); }else{ builder.setMessage("確認撥打"+app.CurrentChildren.childrenName+"的班主任老師電話嗎?"); builder.setTitle("提示"); builder.setPositiveButton("確認", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+children_Data.TeaherBean.getMobilePhone())); startActivity(intent); dialog.dismiss(); } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); } builder.show(); }