2016-03-27 10 views
0

Ben iki radyo düğmesi oluşturmak zorunda gösterilmiyor.Java Android Radyo Düğmesi

final RadioButton Bluetooth = new RadioButton(this); 
Bluetooth.setId(TEXT_ID); 
alertDialogBuilder.setView(Bluetooth); 
Bluetooth.setText("Bluetooth"); 
Bluetooth.setTextSize(20); 

final RadioButton RS232 = new RadioButton(this); 
RS232.setId(TEXT_ID); 
alertDialogBuilder.setView(RS232); 
RS232.setText("RS232"); 
RS232.setTextSize(20); 
+0

Lütfen düzeninizi de paylaşın xml! – KostasC

+0

Üzgünüz, ama XML'im yok. Amaç, iki RadioButton'u bir alertdialog'a eklemek. Kullanıcı madde menüsünü tıkladığında alertdialog görüntülenir. – McNavy

cevap

0

kullanın bu kod uyarı iletişim kutusu tanımlamak için:

Bu benim kodudur. İki radyo düğmesi içeren bir xml düzeni oluşturun ve daha sonra java'da uyarı iletişim kutusunda görünüm ve inflathat görünümü oluşturun.

   View view2 = View.inflate(MyActivity.this, R.layout.radiobutton, null); 

       AlertDialog.Builder builderconversion = new AlertDialog.Builder(MyActivity.this); 
       //builder1.setMessage("Radio Message"); 
       builderconversion.setView(view2); 
       builderconversion.setCancelable(true); 
       builderconversion.setPositiveButton("CLOSE", 
         new DialogInterface.OnClickListener() { 
          public void onClick(DialogInterface dialog, int id) { 

           //Methods and functions 
           dialog.cancel(); 
          } 
         }); 

       AlertDialog alertconversion = builderconversion.create(); 
       alertconversion.show(); 
+1

Yardımlarınız için teşekkürler. Düzen dizininde yeni bir XML dosyası oluşturacağım. Ve eğer işe yararsa göreceğim. – McNavy