Android autocompletetextview dropdown box's elements have a large font - android

I would like to change the autocomplete dropdown boxes element size to something smaller.
Any change i do with textview.settextsize affects only the value in the fieldbox and not in the drop down box!
I am adding the list items dynamically and my adapter is set to the resource
adapterForFromAutoText.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
Should i add my own resource to customize the style of the font, if so does it matter that i use adapterForFromAutoText.add(displayName); to dynamically add data through the adapter.

Do you have the attribute "android:textSize" within your "android.R.layout.simple_dropdown_item_1line"? You may want to try to change the textSize there.
You may also want to check out this tutorial.

Use This Layout , It will change the autocomplete dropdown boxes element size to smaller
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, aList);

Related

How to change spinner item text color programmatically without using adapter when set its state as disabled

I am using a spinner in my application and setting its item values via xml. I have set spinner item default color via style, I have to enable and disable my spinner as required in my application.
I want to change its item color programmatically when I set its state disable. I have searched through google but could not find any solution for this.Is there anyone who has any idea about this how can I set it.I have used this link how do you set the spinner text color?, but it is giving null pointer exception.
m_spnDia = (Spinner)findViewById(R.id.spiDia);
TextView oTextView = (TextView)m_spnDia.getChildAt(0);
oTextView.setTextColor(Color.RED);
You can create custom layout for your spinner item as like created here :
How to change spinner text size and text color?
and use it inside your ArrayAdapter.
Now, As per your requirement you have to create two xml files to provide two different colors to spinner items :
1) When your Spinner is Enabled.
2) When your Spinner is Disabled.
Just change the line below as :
if(spinner1.isEnabled){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinner_item1,list);
}else{
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinner_item2,list);
}

How to add icon to spinner (where find the default value)

how i add icon to spinner by xml where find the default value (not in the the list) ??
<Spinner
android:id="#+id/spinner1"
android:layout_gravity="center"
android:layout_weight="0.28"
android:prompt="#string/language_prompt"
android:textSize="12sp" <!-- icon insten of text -->
/>
i try android:Background="#drawable/world_language_icon" but doesn't work.
i dont find src or set drawable .
I dont find here (in google)
i need xml and not javaalso here i find in java
First of all, you should probably try proof reading your question before posting, and make sure you know exactly what you want to know.
how i add icon to spinner by xml
The icon is not added to the spinner itself, as what you use to populate the Spinner is an adapter. In order to add an icon to your Spinner items, you would need to create a custom adapter to set to the Spinner, and use a custom layout for the List Items.
where find the defult value (not in the the list) ??
That, I'm not sure what you are asking for. If your question is how to set a default item/value for the Spinner, it's not possible. The default item set will always be the first item on the List you populate the Spinner with. You can of course automatically select a different Spinner item in code, but even then you'll notice that the first item was selected before your other actions.

Spinner Text Not Visible

I am trying to setText in Spinner but is not visible in device. (Visible in emulater) .
Please give solution for this.
You cant settext to spinner with settext(). You have to use ArrayAdapter for displaying the content in spinner. like this,
Declare an array-
String[] type_array = {"Monthly","Quaterly","Yearly"};
In onCreate()-
spinner_type = (Spinner) findViewById(R.id.spinner_type_susa);
spinner_type.setOnItemSelectedListener(this);
ArrayAdapter<String> adapter_type = new ArrayAdapter<String>(this,R.layout.spinner_row,type_array);
adapter_type.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_type.setAdapter(adapter_type);
You gave the text a holo color that is only available on a high API level and your device doesn't know what to do with it so it gave the default color of text which is black, which just happens to be the color of the background in your spinner. Yes this is a wild guess.

AutoCompleteTextView remove/change color divider

Is it possible to remove/change color of the delimiter in AutoCompleteTextView's popup ? In ListView I get use of the "delimiter" parameter, but I haven't found any similar in AutoCompleteTextView.
Thanks.
Use an Adapter for your AutoCompleteTextView.
Then, you can do something like this :
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
The layout can be configured by you.
A quick fix solution, for removing the divider, might be writing a custom XML to override the style for each cell (Through the SetDropDownViewResource). After that you can change the android:popupBackground property on the autocompletetextview to match it to the color of your item's background.

How to use a personalized spinner with programatically created array of Strings instead of a hard-coded string array of my strings.xml file?

i have a personaliced spinner (that uses a adapter that uses a personalized xml layout file)
i want to pass him a array of strings, programatically created, instead of passing the tipical hard coded string array of strings.xml... but i can't!! if i try to pass a array of strings, eclipse tell me that he needs a reference of a item from resources (a hard coded string array from strings.xml)
also i tryed to use the answer of this another way: Android: Create spinner programmatically from array
but that way didn't work's for me, because that way must use the default layout android.R.layout.simple_spinner_item and i won't work with that layout, i need to use my personalized layout (R.layout.spinner_layout), and that method didn't let me to use personalized layouts for the spinner
this is my code:
String[] teams=(String[])Primera.getTeams().toArray();
ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.teams_array, R.layout.spinner_layout);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
TeamsSpinner.setAdapter(adapter);
TeamsSpinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
i need to changue R.array.teams_array, to teams, but i can't because the reason i told some lines up
can anyone help me ?
thanks
You do not have to use the android.R.layout.spinner_item etc. like what is being used in the question you reference. You can use your own layout xml for the spinner item.
You do not have to use ArrayAdapter.createFromResource() you can use:
ArrayAdapter adapter = new ArrayAdapter(this, R.id.your_custom_spinner_item, teams);

Categories

Resources