2012-02-18 96 views

回答

1

創建延伸類對話框,它充氣佈局

public class CustomDialog extends Dialog 
    { 
     public CustomDialog (Context context) 
     { 
      //use this Theme, or any other theme you like 
      super(context, android.R.style.Theme_Translucent_NoTitleBar); 

      requestWindowFeature(Window.FEATURE_NO_TITLE); 

      setContentView(R.layout.your_layout); 
     } 
    } 
0

您可以隨時膨脹自己的自定義對話框佈局。

LayoutInflater inflater = getLayoutInflater(); 
View dialoglayout = inflater.inflate(R.layout.dialog_layout, (ViewGroup)  findViewById(R.id.dialog_layout_root)); 
AlertDialog.Builder builder = new AlertDialog.Builder(this); 
builder.setView(dialoglayout); 
+0

以及如何實現按鈕和複選框?代碼:final CheckBox check =(CheckBox)dialog.findViewById(R.id.checkBox1);不會工作 – 2012-02-18 10:38:53

+0

您應該將其稱爲root_layout.findViewById,其中根佈局是您已經膨脹的主佈局。 – 2012-02-18 10:46:02

+0

我該怎麼解僱對話? – 2012-02-18 10:51:08

1

您可以使用自定義對話框並將設計的xml充氣到其中。

final Dialog yourDialog=new Dialog(context); 
thumbnail_click.setContentView(R.layout.yourlayout); 
0

如果你還沒有得到一個答案,這裏是一個很好的toturial:Toturial

您VILL需要使自己的XML形式的文件,並使用邊角功能例如:

<corners android:bottomLeftRadius="5dp" android:bottomRightRadius="5dp" /> 
相關問題