- Forum posts: 1
Aug 3, 2014, 7:17:15 PM via Website
Aug 3, 2014 7:17:15 PM via Website
I am using C# as language in vs 2010 and I am new to android.
I have created an xml file with three text box and two button.
I want to know how to access this button event and values of editText from main activity.
I use this code and I don't know weather it is correct.
public class Activity1 : Activity
{
protected override void OnCreate(Bundle bundle)
{base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
//SetContentView(Resource.Layout.DefaultValue);
Button button = FindViewById<Button>(Resource.Id.Btn_Default);
Button Btnsave = FindViewById<Button>(Resource.Id.BtnSave);
button.Click += delegate
{
var Ratio = new AlertDialog.Builder(this);
Ratio.SetView(LayoutInflater.Inflate(Resource.Layout.DefaultValue ,null));
Ratio.SetTitle("Select Ratio");
Ratio.Create().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();
};
}
}
My Xml File name is DefaultValue and Btnsave is the button
when I run without Btnsave.Click event then program runs but with this it not running
— modified on Aug 3, 2014, 7:19:08 PM
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.