Why does Android AlertDialog set setSingleChoiceItems to not display the list? [setMessage and setSingleChoiceItems cannot be used at the same time], setsinglechoiceitems

Source: Internet
Author: User

Why does Android AlertDialog set setSingleChoiceItems to not display the list? [setMessage and setSingleChoiceItems cannot be used at the same time], setsinglechoiceitems

Today I wrote a simple function, such as a question. The result list is not displayed.

The code is rewritten once, and it is found that setMessage and setSingleChoiceItems cannot be used at the same time.

Correct:

Private void mobilePhone () {AlertDialog. builder builder = new AlertDialog. builder (HomePageChildrenActivity. this. getParent (); if (children_Data.schoolbean.schType.equals ("K") {// kindergarten 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 ("select a instructor"); builder. setSingleChoiceItems (teachers, 0, buttonOnClick); builder. setPositiveButton ("OK", buttonOnClick); builder. setNegativeButton ("cancel", buttonOnClick);} else {builder. s EtMessage ("are you sure you want to call" + app. CurrentChildren. childrenName +? "); Builder. setTitle ("prompt"); builder. setPositiveButton ("OK", 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 lephone. dismiss () ;}}); builder. setNegativeButton ("cancel", new DialogInterface. onClickListener () {@ Override public void onClick (DialogInterface dialog, int which) {dialog. dismiss () ;}}) ;}builder. show ();}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.