Android : How to get the textview value and compare [duplicate] - android

This question already has answers here:
Convert number in textview to int
(5 answers)
Closed 1 year ago.
Iam a newbie So
How to get the number value of textview and compare it that if it less than a 100 for example some other textview text changes to whatever i want ????
for example that if {textview1 < 25 || > 100}
i want to change the textview2 text to be "Hello"
else textview2 text "Goodbye"
Iam using fragment Activity

Should be something like this
textview2.Text = if (textview1.Text.ToInt() < 25 || textview1.Text.ToInt() > 100) "Hello" else "Goodbye"

Related

How to display number with all decimal (not Science notation) android? [duplicate]

This question already has answers here:
How do I print a double value without scientific notation using Java?
(18 answers)
Closed 11 months ago.
How can I show the full number instead of the scientific number when you perfonm a division this long.
9.34429093014885 / 10000000
I want to display:
0.000000034429093014885
But it keep returning:
9.34429093014885E-7
JAVA
Double value = ( price / exponent);
BigDecimal.valueOf(9.34429093014885 / 10000000).toPlainString()
Gives your expected result

Showing only 2 digits after dot in Double with kotlin [duplicate]

This question already has answers here:
How to round a number to n decimal places in Java
(39 answers)
round up to 2 decimal places in java? [duplicate]
(12 answers)
Closed 1 year ago.
val yield = (((sun * air)/ (cel+pco))*100).toDouble()
I have an assignment like this. As a result, it shows many numbers after the dot, for example 12.3456712345. I just want it to show as 12.34.

How to count word in TextView Android Studio [duplicate]

This question already has answers here:
how to count the number of words in Kotlin Android?
(5 answers)
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Suppose In my app I have two textview, first one name is ViewText and the second one is WordCount.
I want to show some text in ViewText and WordCount shows how many words in ViewText.
How can I count words in textview in Android Studio?
Try this one
val words = "Hi this is sentence for counting words"
var totalCount = words.split("\\s+".toRegex()).size
println(totalCount)

how to Check Float value Is Null Or not? [duplicate]

This question already has answers here:
How do I check if my EditText fields are empty? [closed]
(30 answers)
Does EditText.getText() ever returns null?
(7 answers)
Closed 4 years ago.
I have some EditText which is of "numberDecimal", and One Button. When user clicks on button, data goes to Database. So how to check EditText is empty or not. I am getting error when I try to parse the EditText.
To check an edittext is empty:
EditText ed = (EditText) findViewById(R.id.ed);
age = ed.getText().toString();
if (age.matches("")) {
Toast.makeText(this, "Empty", Toast.LENGTH_SHORT).show();
return;
}
You can also use equals() instead of matches()

How to Count numbers of line, word and characters from Edittext field in Android [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am beginner, I want to make one simple application that will count number of lines, words and characters from whatever we have entered in Editext field. i want result like:
EditText : My name is abc.
Button CLick---->
Result:
No. of Words : 4
No. of Characters : 14
No. of Lines : 1
First get the Edittext value.then do like as java word counter
EditText e1=(EditText) findViewById(R.id.youredittextid);
String mytext=e1.getText().toString();
Apply java code for mytext
lines in edittext can vary depending on device....
for words:
char ch[]= new char[s.length()]; //in string especially we have to mention the () after length
for(i=0;i<s.length();i++)
{
ch[i]= s.charAt(i);
if( ((i>0)&&(ch[i]!=' ')&&(ch[i-1]==' ')) || ((ch[0]!=' ')&&(i==0)) )
c++;
}
and for characters: s.length()

Categories

Resources