今日写了个如题目的简单功能,结果列表不显示
无奈重写了一次代码发现setMessage和setSingleChoiceItems不能同时使用。
正确的如下:
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();
}