From 76cd2d87281452835edeacaa42b77d4fd22d1a53 Mon Sep 17 00:00:00 2001 From: Sam Hos Date: Thu, 18 Apr 2024 15:08:45 +0200 Subject: [PATCH] Added class to change text on a layout --- .../java/com/fitbot/fitbot/TextSetter.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 code/src/app/src/main/java/com/fitbot/fitbot/TextSetter.java diff --git a/code/src/app/src/main/java/com/fitbot/fitbot/TextSetter.java b/code/src/app/src/main/java/com/fitbot/fitbot/TextSetter.java new file mode 100644 index 0000000..7bb7f93 --- /dev/null +++ b/code/src/app/src/main/java/com/fitbot/fitbot/TextSetter.java @@ -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 \ No newline at end of file