- Forum posts: 1
Aug 30, 2017, 7:30:27 PM via Website
Aug 30, 2017 7:30:27 PM via Website
Good Day Everyone
I have an activity class defined like this
[Activity(Label = "Activity_Home", MainLauncher = false, Icon = "@drawable/lenderlogo", Theme = "@style/MyTheme")]
public class Activity_Home : ActionBarActivity //AppCompatActivity
{
and the activity is hosting a Tab that display its content from a fragment. A fragment is defined separately and it has a button that is defined like this
<Button
android:textSize="10sp"
android:textColor="#FFF"
android:id="@+id/btn_details_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="btn_details_saveClick"
android:text="Continue" />
as you can see i have a click event that is triggered when the button is clicked. The code to handle the event of the button is defined in the fragment class file like this
//Find Controls to hook
Button btn_details_save = FindViewById<Button>(Resource.Id.btn_details_save);
// set onclick listener here, by deleting some process
btn_details_save.Click += delegate
{
btn_details_saveClick();
};
and he function itself is defined like this
public void btn_details_saveClick()
{
//Do stuff
}
Now when i run the application, the button is click the button the following error occurs
AndroidRuntime(19059): java.lang.IllegalStateException: Could not find method btn_details_saveClick(View) in a parent or ancestor Context for android:onClick attribute defined on view class Button with id 'btn_details_save'
Please note that this is C# code , which means i am using xamarin ,but the error is Android related not Xamarin.
Thanks
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.