Added class to change text on a layout

This commit is contained in:
2024-04-18 15:08:45 +02:00
parent 50033a2180
commit 76cd2d8728

View File

@@ -0,0 +1,18 @@
package com.fitbot.fitbot;
import android.app.Activity;
import android.widget.TextView;
public class TextSetter {
public static void setCustomText(Activity activity, int textViewId, String text) {
TextView textView = (TextView) activity.findViewById(textViewId);
textView.setText(text);
}
}
// usage:
// TextSetter.setCustomText(this, R.id.testText, "Bruh");
// r.id.testText is the id of the textview in the layout file
// "Bruh" is the text to be set
// make sure you have the right layout set in MainActivity.java with the setContentView method