protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView (Resource.Layout.Main);
var btn = FindViewById<Button>(Resource.Id.button1);
btn.Click += delegate
{
var popup = FindViewById<LinearLayout>(Resource.Id.linearLayout1);
var btncamera = popup.FindViewById<Button>(Resource.Id.btnCamera);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetView(Resource.Layout.popup);
builder.Show();
btncamera.Click += delegate
{
builder.Dispose();
};
};
}
谢谢
答案 0 :(得分:0)
你做错了
所以改变你的代码
btn.Click += delegate
{
var popup = FindViewById<LinearLayout>(Resource.Id.linearLayout1);
var btncamera = popup.FindViewById<Button>(Resource.Id.btnCamera);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetView(Resource.Layout.popup);
builder.Show();
btncamera.Click += delegate
{
builder.Dispose();
};
};
这样
btn.Click += delegate
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.LayoutInflater;
var dialogView = inflater.inflate(Resource.Layout.linearLayout1, null);
builder.SetView(dialogView);
var btncamera = builder.FindViewById<Button>(Resource.Id.btnCamera);
builder.Show();
btncamera.Click += delegate
{
builder.Dispose();
};
};