2011-09-07 113 views
3

我正試圖找到一種方法來爲某些包含單選按鈕,editText,按鈕的用戶輸入創建彈出屏幕。我不想開始新的活動。 什麼是一個好的選擇? AlertDialog? Spinner?彈出式菜單? 謝謝Android彈出對話框

+0

警報對話框應該能夠做你想做的。你看過AlertDialog API:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlertDialogSamples.html – slayton

回答

7

AlertDialog會很好。您可以使用所有您需要的組件聲明一個layout.xml文件,然後將其充氣並將其設置爲對話框的內容。

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View layout = inflater.inflate(R.layout.yourLayoutId, (ViewGroup) findViewById(R.id.yourLayoutRoot)); 
    AlertDialog.Builder builder = new AlertDialog.Builder(this) 
    .setView(layout); 
    AlertDialog alertDialog = builder.create(); 
    alertDialog.show(); 
+0

你是如何解僱它的? – steveh