• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

how to access event of a control from another xml in main activity

babucr

Lurker
Hai

I have declared a button (BtnSave )in an xml file called defaultvalue

I want to access this control in main activity, Please tell me how to do this.

I use this code (C#)


thanks.

Main activity

publicclassActivity1 : Activity
{
protectedoverridevoidOnCreate(Bundlebundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
SetContentView(Resource.Layout.DefaultValue);
Buttonbutton = FindViewById<Button>(Resource.Id.Btn_Default);
ButtonBtnsave = FindViewById<Button>(Resource.Id.BtnSave);



button.Click += delegate
{
varRatio = newAlertDialog.Builder(this);
Ratio.SetView(LayoutInflater.Inflate(Resource.Layout.DefaultValue ,null));
Ratio.SetTitle("Select Ratio");
Ratio.Create().Show();
Toast.MakeText(this, "you clicked on " ,
ToastLength.Short).Show
();
};


Btnsave.Click += (sender, e) =>
{
var Ratioc = new AlertDialog.Builder(this);
Ratioc.SetView(LayoutInflater.Inflate(Resource.Layout.DefaultValue, null));
Toast.MakeText(this, "you clicked on " + Btnsave.Text,ToastLength.Long).Show();
Ratioc.Create().Dismiss();
};
}
}
 
Back
Top Bottom