How to reference a function in a java Activity file to a xml layout file in AIDE?
I have never used AIDE myself, but I assume you are still able to edit the xml and java code? Write your function in java (suppose it is called doSomething
), then call it when the button is clicked on. You can accomplish this two different ways.
1) Hook it up via xml
<Button
android:id="@+id/my_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_text"
android:onClick="doSomething"/>
2) Hook it up via java
Button button = (Button) rootView.findViewById(R.id.my_button);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
doSomething();
}
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments