want to disable the radio button appearing on spinner after selection - android

Hi friends wanna remove the radio button appearing on spinner.. Which is increasing the layout size of my dialog.. Thanks in advance..

set your spinner's adapter as follow:
adapterSpinner = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, new String[]{"1", "2"});
adapterSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

For this you need to change your Spinner Style
ArrayAdapter<String> adapter = new ArrayAdapter<String>(Registration.this,android.R.layout.simple_spinner_item, Your Array);
spinner.setAdapter(adapter);

Related

Set Spinner adapter then EditText input type changed

I have set spinner to ArrayAdapter as String list.
// Creating adapter for spinner
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(LoginActivity.this, R.layout.row_spinner, countryCodeList);
dataAdapter.setDropDownViewResource(R.layout.row_spinner);
// attaching data adapter to spinner
spinnerCountryCode.setAdapter(dataAdapter);
In this set spinner adapter successfully but LoginActivity I have also other EditText control as InputType number.
My problem is after spinner adapte set click on Edittext then first open number keyboard and then after immediate open system text keyboard.
I have also set EditText input type as number
android:inputType="number"
And manifest file set windowSoftInputMode is
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
Please suggest me some solution.
Thanks in advance..!
something is wrong with your R.layout.row_spinner , try adding android.R.layout.simple_spinner_item in place of R.layout.row_spinner and run once
ArrayList<String> values;
values = new ArrayList<>();
values.add("value1");
values.add("value1");
values.add("value1");
values.add("value1");
// Creating adapter for spinner
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_spinner_item, values);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
// attaching data adapter to spinner
spinner.setAdapter(dataAdapter);

Android: Align items and title/prompt in "Dialog" mode Spinner

I have a spinner that's populated like this:
Spinner spinner = (Spinner) findViewById(R.id.m_spinner);
final ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_item, spinnerValuesList);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(spinnerAdapter);
spinner.setPrompt("CPU Frequency Governor");
It's created like this:
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:spinnerMode="dialog"
android:id="#+id/my_spinner"/>
Everything works fine, but I'd like to align the text of the dialog title and the spinner items. I attached a picture to show what it currently looks like and what I'm looking to achieve.
Thanks
Instead of
final ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_item, spinnerValuesList);
Try this:
final ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1
, spinnerValuesList);
Let me know if it works for you.

Android programming spinner swap elements of spinner

need to do so when you click on a specific button (application type translator and arrow key) changed one of the selected items to another spinner itam swapped Well, here is how it can be implemented?
here is the code but it does not work!
int spinner1Index = spinner.getSelectedItemPosition();
spinner.setSelection(spinner2.getSelectedItemPosition());
spinner2.setSelection(spinnerfirst);
can offer something similar or fix!
You would have to change the adapter of your spinner and call notifyDataSetChanged()
I would suggest adding this to your switch case for when the item is selected.
Set a custom adapter for the spinner on item click.
//An array of what you want to populate the spinner with
Array spinnerArray [] = {"One", "Two", "Etc.."};
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, spinnerArray);
spinnerArrayAdapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
//Before setting the adapter, clear and notify the previous ArrayList used
arrayList.clear();
arrayList.notify();
spinner.setAdapter(spinnerArrayAdapter);

How to set the spinner mode dynamically?

I have created a Spinner dynamically, which is easy with new Spinner(context).
But now I need to set the spinnerMode dynamically, and I find no method to do so.
What should I do?
in android >= 3.0 (API 11) you can use this :
Spinner spinner = new Spinner(this,null,android.R.style.Widget_Spinner,Spinner.MODE_DROPDOWN);
OK you can try with..
Spinner spinner = new Spinner(this);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, yourArrayAdapter);
spinner.setAdapter(spinnerArrayAdapter);
Or,
Spinner spinner = new Spinner(this);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, yourArrayAdapter);
spinner.setAdapter(spinnerArrayAdapter);
Also you can see..
How to set spinnerMode in Android 2.2?

issues in spinner Android?

Hai i developed a application in android,in my application i used a dynamically created spinner(many spinner),the width in 320
problem
when 1 spinner text is like"aaaa",2 spinner text is like "a".the two spinner width is varied.i need the same width in all spinner.how to do?Anybody kindly solve my problem.
Spinner spinner = new Spinner(this);
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_dropdown_item,
spinnerArray);
spinner.setAdapter(spinnerArrayAdapter);
you need to set width attribute of the spinner.I think it is "set to wrap content".You should provide width in dp.Foe ex-100dp
LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
yourspinner.setLayoutParams(params);
you can also give height and width in DP. Check this method.
Try to create the spinner in XML layout with the width value and set visibility "GONE".
When you have to use it, you can retrieve it by using findviewbyid method and then you have to set the visibility at VISIBLE.
Spinner spinner = (Spinner)findViweById(R.id.spinnerInvisible);
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_dropdown_item,
spinnerArray);
spinner.setAdapter(spinnerArrayAdapter);
spinner.setVisibility(View.VISIBLE);

Categories

Resources