MainActivity Need help setting the text to “You must enter a name” when the nameText is null. For some reason even when the nameText field is empty it still outputs “Hello” when it should be outputting “You must enter a name”. Answer Probably you need to check if the text of your EditText is null, not the EditText widget itself.
Tag: textview
How to adjust Text Views in different Screens (Android Studio)
I’ve search for all Internet but can’t figure this out, i have my textviews on my Images, when I rotate the phone or change to other screen size, the Text won’t adapt like i want (left image) i already tried app:autoSizeTextType=”uniform”, wrap content, match parent, but this won’t do. Image my xml Answer You can create a new layout for
How to get “Text” in TextView from RealTime Firebase
How to get text in TextView from RealTime Database using Java? Answer To get the value of “text” field that exists under your “app_billing” node, please use the following lines of code:
Make display data textviews invisible until a city is searched
I set my textviews on my weather app to display the data for cities when searched on my search panel (i.e temp_out.setText(response.body().getMain().getTemp() + ” ℃”););. It works quite fine only that the textviews used to display those data still reflect on the app(i.e temp_out). I want to set it up in such a way that the textviews will be invisible
Disable text wrapping in Android
I’m working on a project in Android where I have a TextView (an EditText to be exact) and a setting to enable or disable text wrapping for that view. I have searched the internet (a lot) but still haven’t found any satisfying solution. Currently I’m using a NestedScrollView for the vertical scrolling and then dynamically insert one of two partial
How to change Textview text in Activity from class that extends RelativeLayout
In my MainActivity I have one TextView. Now, inside other class that extend Relative Layout, I have implemented one MessageListener that (using onNewMessage method) recieve every second some values. I want to put this values inside my TextView that are in MainActivity. This is a simply example of my class: Thanks for help. Answer If you call this Class in
How to only let Edit Text accept Letters which are in Textview
I have an edit text however I only want letters which are in another Text view to be typeable. For example if the Text view say Hello Only H,E,L and O should be Typeable. Answer Using this code you can get it to only accept your String
Android/Java: how to set background color of MaterialShapeDrawable with int Color?
I have a TextView with rounded corners. Here is my code: Now, I want to change programmatically the background color of the textView. When I do : it works; the background color is changed. Now, I want to change the background color with an int color like Color.RED or any random color defined with Color.RGB(r, g, b, a) or Color.RGB(r,
Java create a TextView without open new window
This is my code: LinearLayout linearLayout = new LinearLayout(this); setContentView(linearLayout); linearLayout.setOrientation(LinearLayout.VERTICAL); // Open new window …
TextView setContentDescription not working
I’m trying to set the contentDescription on a TextView but it doesn’t seem to be announced by TalkBack. TalkBack is only vocalizing the text content. The second line above has no effect. TalkBack says, “2d 9h left”. I’ve also tried the following: but this results in TalkBack announcing “2days 9hours left 2d 9h left”, which is also incorrect. Answer The