Added class to change text on a layout
This commit is contained in:
18
code/src/app/src/main/java/com/fitbot/fitbot/TextSetter.java
Normal file
18
code/src/app/src/main/java/com/fitbot/fitbot/TextSetter.java
Normal 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
|
Reference in New Issue
Block a user