2012-02-18 188 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" /> 
相关问题