On tab key request focus on spinner-Android [duplicate] - android

This question already has answers here:
Spinner does not get focus
(4 answers)
Closed 10 years ago.
I have a registration form where flow goes as EditText1->EditText2->Spinner->Editext3 ,but on tab press the of EditText2 control is transferred to editText3 and not Spinner How can i do that in android??Can anyone help plz

Use this before your Oncreate()
Spinner spin = (Spinner) findViewById(R.id.spinner1);
spin.setFocusable(true);
spin.setFocusableInTouchMode(true);
spin.requestFocus();

Related

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 change EditText hint color in android [duplicate]

This question already has answers here:
Design Android EditText to show error message as described by google
(7 answers)
Closed 5 years ago.
I have a login
If user don't enter username or password and press "login" button, the EditText hint will warn you, like thislogin(turn red). How can I implement this?
I think you should set error instead
editText.setError(getString(R.string.error_required));
but if you want that
editText.setHint()
editText.setHintTextColor
Based on the image you have posted , it is very simple to show that hint when there is no data entered in username/password fields.
if(username.isEmpty())
{
usernameEditTextView.setHint("please enter username");
usernameEditTextView.setHintTextColor(R.color.Red);
}

How to hide first item in an android spinner dropdown? [duplicate]

This question already has answers here:
How to make an Android Spinner with initial text "Select One"?
(36 answers)
Is it possibile to set hint Spinner in Android [duplicate]
(3 answers)
Closed 6 years ago.
I'm using adapter.add for adding a title in my spinner, but how to hide first item in an android spinner dropdown?
Here is My Code:
var spinner1 = FindViewById<Spinner>(Resource.Id.spinner1);
var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem);
spinner1.Adapter = adapter;
adapter.Add("Select one...");
adapter.Add("Name");
adapter.Add("Mobile");
adapter.Add("Age");
See images below:

Set the default Text into spinner programmatically [duplicate]

This question already has answers here:
How to make an Android Spinner with initial text "Select One"?
(36 answers)
Closed 9 years ago.
I have a spinner like this:
Spinner spinner = new Spinner(context);
spinner.setPadding(0, 10, 10, 0);
ArrayAdapter<ItemValue> aa = new ArrayAdapter<ItemValue>(context,
android.R.layout.simple_spinner_item,elemItemSet);
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(aa);
Now I need a add a default/initial text programmatically (without using xml) & without adding into list 'elemItemSet'.
Is it possible?
To show defualt value(Select) at spinner,you have to add "Select" text into your array list at O index. And apply condition like "When the value of spinner is 'select' then show message to user like 'Select any value'".
I hope it will help you.
Thnaks

Categories

Resources