This is my first attempt at Fragments, and I cannot process android: onClick
I have a button inside my XML fragment like
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/save_keywords_button"
android:id="@+id/save_keywords"
android:layout_marginTop="340dp"
android:background="#FF2E7D32"
android:textColor="#FFFFFF"
android:typeface="normal"
android:onClick="myLogic" />
I searched a lot of results and cannot get the exact solution to handle the onClick event.
My question is: how can I get the identifier of my button and write myLogic method. FindViewById () does not work in fragments and where should the method be written? in a fragment or in my activity?
source
share