In my activity i have two spinners, one image view and two buttons.
depending on first spinner the second spinners should change. and while selecting birds in first spinner the second spinner should show parrot peacock etc. while selecting parrot in second spinner i should get the image of parrot.
till this i am getting.
but now what i want is while i press a button then i should get the voice of parrot.
in this code when i am pressing the button i am getting the same voice for every picture change in second spinner
public class MainActivity extends Activity {
ImageView displayIV;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
;
Button b1;
b1=(Button)findViewById(R.id.button1);
Spinner friend = (Spinner) findViewById(R.id.spinner1);
final Spinner subFriend = (Spinner) findViewById(R.id.spinner2);
displayIV=(ImageView)findViewById(R.id.imageView1);
final ArrayList<String> friend_options = new ArrayList<String>();
final ArrayList<String> subfriend_options = new ArrayList<String>();
friend_options.add("Nuz");
friend_options.add("Dur");
friend_options.add("Tara");
friend_options.add("Sama");
ArrayAdapter<String> friendAdapter = new ArrayAdapter<String>(
getApplicationContext(), android.R.layout.simple_spinner_item,
friend_options);
friend.setAdapter(friendAdapter);
ArrayAdapter<String> subFriendAdapter = new ArrayAdapter<String>(
getApplicationContext(),
android.R.layout.simple_spinner_item,subfriend_options);
subFriend.setAdapter(subFriendAdapter);
friend.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> arg0, View view,
int position, long id) {
String friendName =
friend_options.get(position).toString();
resetFriend(friendName);
// subFriend.setAdapter(null);
}
private void resetFriend(String friendName) {
subfriend_options.removeAll(subfriend_options);
if (friendName.equals("Nuz")) {
subfriend_options.add("Nuz_1");
subfriend_options.add("Nuz_2");
subfriend_options.add("Nuz_3");
subfriend_options.add("Nuz_4");
} else if (friendName.equals("Dur")) {
subfriend_options.add("Dur_1");
subfriend_options.add("Dur_2");
subfriend_options.add("Dur_3");
subfriend_options.add("Dur_4");
} else if (friendName.equals("Tara")) {
subfriend_options.add("Tara_1");
subfriend_options.add("Tara_2");
subfriend_options.add("Tara_3");
subfriend_options.add("Tara_4");
} else {
subfriend_options.add("Sama_1");
subfriend_options.add("Sama_2");
subfriend_options.add("Sama_3");
subfriend_options.add("Sama_4");
}
ArrayAdapter<String> subFriendAdapter = new
ArrayAdapter<String>( getApplicationContext(),
android.R.layout.simple_spinner_item,
subfriend_options);
subFriend.setAdapter(subFriendAdapter);
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
subFriend.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
arg0.getItemAtPosition(arg2);
final ImageView im =
(ImageView)findViewById(R.id.imageView1);
String s=((TextView)arg1).getText().toString();
if(s.equals("Tara_1")){
im.setImageDrawable(getResources().getDrawable(R.drawable.crow));
}
if(s.equals("Tara_2"))
im.setImageDrawable(getResources().getDrawable(R.drawable.india1));
if(s.equals("Tara_3"))
im.setImageDrawable(getResources().getDrawable(R.drawable.peacock));
if(s.equals("Tara_4"))
im.setImageDrawable(getResources().getDrawable(R.drawable.robin1));
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
b1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//MediaPlayer mMediaPlayer = MediaPlayer.create(this,
R.raw.Kalimba);
MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.abc);
mp.start();
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
In the setOnClickListener method of your button, b1, you need to know which image has been selected on the spinner (your description is a little bit confusing so i don't have clear exactly which spinner is going to change the sound that you app has to reproduce).
Anyway, let think that the spinner is "friend_options".
In you setOnClickListener we have to know which item has been selected for the user when click on the button, right? And depending of which item was selected, we will play one specific sound.
So....
Another important poin is that you should create the variable of the mediaplayer outside of the onclickListener, like a class variable:
//Class variable:
public MediaPlayer mp;
In the onCreate method you should initialize the MediaPlayer component:
public void onCreate()
{
MediaPlayer.create(MainActivity.this, R.raw.abc); //Default sound, it is not
//importat because we are going
//to chain the value of the
//file to reproduce in the next
//step.
}
b1.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
//Here we are going to take the item selected:
String itemSelected = spinner.getSelectedItem().toString();
int soundToPlayId=0;
if(itemSelected.equals("Nuz"))
{
soundToPlayId = R.raw.Kalimba ;
}
else if(itemSelected.equals("Dur"))
{
soundToPlayId = R.raw.abc;
}
// etc etc etc --> you should put all the sound associated to all the
// friends
//And now you only have to reproduce if the item was selected properly:
if(soundToPlayId !=0) //if the id is different to 0:
{
mp = MediaPlayer.setDataSource(MainActivity.this, soundToPlayId);
mp.start();
}
}
});
Let see if it is working!!! Ask me if you have any doubt...and if the answer is correct, vote me and check as correct!!! (I need points, thanks!)
Related
I got a problem with playing two MediaPlayers simultaneously.
In my code I made a spinner to let the user to choose his first song and then the second song, at the moment that the user chooses the first song it starts to play and when the user choose the second song it will play with the first one.
But the problem is that, when the user chse the second song it stops the first one...
What can I do to fix it?
Ty!
The code:
public void setSpinner() {
Spinner spine = (Spinner) findViewById(R.id.spinner3);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.song, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spine.setAdapter(adapter);
final MediaPlayer mp1 = new MediaPlayer();
spine.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String st = parent.getItemAtPosition(position).toString();
if (st.equals("First Song")) {
setMedia1(mp1);
mp1.start();
}
if (st.equals("Second Song")) {
setMedia2(mp1);
mp1.start();
}
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
public void setMedia1(MediaPlayer mp2) {
Bundle b1=getIntent().getExtras();
float s = b1.getFloat("speed");
Bundle b2=getIntent().getExtras();
float v = b2.getFloat("volume");
try {
String s1 = getIntent().getStringExtra("song1");
final Uri uri1 = Uri.parse(s1);
mp2.setDataSource(getApplicationContext(), uri1);
mp2.prepare();
mp2.setVolume(v,v);
mp2.setPlaybackParams(mp2.getPlaybackParams().setSpeed(s));
} catch (Exception e) {
}
}
public void setMedia2(MediaPlayer mp2) {
Bundle b3 = getIntent().getExtras();
float sp1 = b3.getFloat("speed1");
Bundle b4 = getIntent().getExtras();
float vo1 = b4.getFloat("volume1");
try {
String s2 = getIntent().getStringExtra("song3");
final Uri uri2 = Uri.parse(s2);
mp2.setDataSource(getApplicationContext(), uri2);
mp2.prepare();
mp2.setVolume(vo1, vo1);
mp2.setPlaybackParams(mp2.getPlaybackParams().setSpeed(sp1));
} catch (Exception e) {
}
}
try SoundPool,its a better method of dealing with multiple audio files at the same time.
Heres the documentation:
http://developer.android.com/reference/android/media/SoundPool.html
Heres the example:
http://examples.javacodegeeks.com/android/android-soundpool-example
Hope this helps
Reference
Try using two MediaPlayer instances. Change your setSpinner method to do something like:
public void setSpinner() {
Spinner spine = (Spinner)findViewById(R.id.spinner3);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.song, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spine.setAdapter(adapter);
// You were only creating a single MediaPlayer instance in your version...
final MediaPlayer mpA = new MediaPlayer();
final MediaPlayer mpB = new MediaPlayer();
spine.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String st = parent.getItemAtPosition(position).toString();
if (st.equals("First Song")) {
// Use mpA for the first song
setMedia1(mpA);
mpA.start();
}
else if (st.equals("Second Song")) {
// Use mpB for the second song
setMedia2(mpB);
mpB.start();
}
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
I do not know if that will get the exact behavior you are looking for, but it stands a better chance at playing two songs simultaneously than using a single MediaPlayer instance.
I am new to android , I have an activity with 3 multiple spinners as bellow
Spinner 1:department
Spinner2:semester
Spinner3:subjects
and one button
spinner1 shows the department on select of department it has to display the semester on select of semester it has to display the subject spinner
NOTE:-SUBJECT SPINNER DEPENDS ON THE SELECTION OF SEMESTER SPINNER AS WELL AS DEPARTMENT SPINNER.
something like country, state, city spinners but suggest me some other ideas to do it because i am using string resources to list the items of spinners
Please help me
Try something like this in your activity.
Firstly, make your activity implement AdapterView.OnItemSelectedListener & View.OnClickListener.
private Spinner mDepartmentSpinner;
private Spinner mSemesterSpinner;
private Spinner mSubjectSpinner;
private Button mButton;
// Values to fill first spinner with.
private String[] mDepartments = {
"Department 1",
"Department 2",
"Department 3",
"Department 4",
};
private String[] mSemesters;
private String[] mSubjects;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initViews();
}
private void initViews() {
// Find the spinners and button, declared in the activity's resource file
mDepartmentSpinner = (Spinner) findViewById(R.id.department_spinner);
mSemesterSpinner = (Spinner) findViewById(R.id.semester_spinner);
mSubjectSpinner = (Spinner) findViewById(R.id.subject_spinner);
mButton = (Button) findViewById(R.id.button);
// Initialise spinner with values, placing them into a textview
mDepartmentSpinner.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.text_view, mDepartments));
// Attach a listener for item selection
departmentSpinner.setOnItemSelectedListener(this);
}
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// Work out which spinner was selected
switch (view.getId()) {
case R.id.department_spinner:
// Get the selected item
String selectedDepartment = mDepartments[position];
// Get values to fill the semester spinner with, based on initial selection.
mSemesters = getSemestersFor(selectedDepartment);
// Initialise spinner with values, placing them into a textview
mSemesterSpinner.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.text_view, mSemesters));
// Attach a listener for item selection
mSemesterSpinner.setOnItemSelectedListener(this);
break;
case R.id.semester_spinner:
// Get the selected item
String selectedSemester = mSemesters[position];
// Get values to fill the subject spinner with, based on second spinner selection.
mSubjects = getSubjectsFor(selectedSemester);
// Initialise spinner with values, placing them into a textview
mSubjectSpinner.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.text_view, subjects));
// Attach a listener for item selection
mSubjectSpinner.setOnItemSelectedListener(this);
break;
case R.id.subject_spinner:
mButton.setOnClickListener(this);
break;
}
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
mButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Please select an option from each spinner.", Toast.LENGTH_LONG).show();
}
});
}
#Override
public void onClick(View v) {
// Go to your new activity, passing the selected subject
Intent intent = new Intent(this, SubjectActivity.class);
intent.putExtra("KEY_SUBJECT", (String) mSubjectSpinner.getSelectedItem());
startActivity(intent);
}
You can get the selected subject in the SubjectActivity like so...
#Override
public void onCreate(Bundle savedInstanceState) {
if (getIntent().getExtras().containsKey("KEY_SUBJECT") {
String subject = getIntent().getExtras().getString("KEY_SUBJECT");
}
}
Code for R.layout.text_view
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
You will need to implement the following methods yourself, I don't know your logic!
private String[] getSemestersFor(String department) {
// your code here
}
private String[] getSubjectsFor(String semester) {
// your code here
}
I have a listview with a series of elements.
The click on an item of listview shows me a custom dialog.
In custom dialog I have a layout with:
A spinner
Two buttons (OK / ANNULLA)
This is the normal situation:
When I select the spinner, he shows a list of items.
When I select an item from the spinner, the text that was present on the buttons disappear in this way:
ps: this does not happen on Android 6.0, but it happens in the lower versions (such as 5.0)
The Code:
public void showDialogTagAssociation (Activity activity, Handler handler,
String msg, final MyOperator elemento, final BluetoothDevice device,
final int position){
mHandler = handler;
//-----------------------------------------------------
// DIALOG
dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
//-----------------------------------------------------
//---------------------------------------------------------------------
// LAYOUT
dialog.setContentView(R.layout.alert_dialog_custom_tag);
**// Spinner element
spinner = (Spinner) dialog.findViewById(R.id.spinner);**
// Spinner click listener
**spinner.setOnItemSelectedListener(new OnSpinnerItemClicked());**
//---------------------------------------------------------------------
//----------------------------------------------------------------------
// BUTTON OK
dialogButtonOK = (Button) dialog.findViewById(R.id.acd_btn_ok);
dialogButtonOK.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Log.d(TAG, "Devo assegnare il tag al nome....");
Log.d(TAG, "Nome: " +tmpNome+"\n" +
"TAG: "+device.getName()+" - "+device.getAddress());
dialog.dismiss();
}
});
// BUTTON ANNULLA
dialogButtonNO = (Button) dialog.findViewById(R.id.acd_btn_no);
dialogButtonNO.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
dialog.dismiss();
}
});
//----------------------------------------------------------------------
dialog.show();
}
**private class OnSpinnerItemClicked implements android.widget.AdapterView.OnItemSelectedListener {**
#Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
//NOME
tmpNome = parent.getItemAtPosition(pos).toString();
}
#Override
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}
Thanks for the future help
Remove that piece of code:
spinner.setOnItemSelectedListener(new OnSpinnerItemClicked());
and the thing which you want will still work.
So I'm very new to android programming, and have no real experience with software building however I do have a basic background with PHP so I get some of the theory behind it all.
I'm currently making a basic Form activity that will store the entries into a DB, which can be recalled in another activity where it can be viewed and edited etc etc.
I have found lots of helpful advice to get to where I am but currently having trouble with how I need to structure the code to implement the DatePicker dialog, the problem I'm facing is the example code for the date picker has
public class MainActivity extends Activity implements OnClickListener {
Where as the code in my project is public class New extends ActionBarActivity {
So when I edit the line to "implements OnClickListener" my spinner drop downs don't like it.
I have tried entering the code in without the "implements OnClickListener"
Please take a look at what I have and point me in the right direction, I need to understand where its going wrong and how it should be structured.
public class New extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new);
//Product List
Spinner productList = (Spinner) findViewById(R.id.product);
String[] products = new String[] { "1", "2", "3" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, products);
productList.setAdapter(adapter);
productList.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
Log.v("products", (String) parent.getItemAtPosition(position));
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
//Reason List
Spinner reasonList = (Spinner) findViewById(R.id.reason);
String[] reasons = new String[] { "A", "B", "C" };
ArrayAdapter<String> adapters = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, reasons);
reasonList.setAdapter(adapters);
reasonList.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
Log.v("reasons", (String) parent.getItemAtPosition(position));
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
//Start Date Picker
private EditText StartDate;
private DatePickerDialog StartdatePickerDialog;
private SimpleDateFormat dateFormatter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new);
dateFormatter = new SimpleDateFormat("dd-MM-yyyy", Locale.US);
findViewsById();
setDateTimeField();
}
private void findViewsById() {
StartDate = (EditText) findViewById(R.id.startdate);
StartDate.setInputType(InputType.TYPE_NULL);
StartDate.requestFocus();
}
private void setDateTimeField() {
StartDate.setOnClickListener(this);
Calendar newCalendar = Calendar.getInstance();
StartdatePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Calendar newDate = Calendar.getInstance();
newDate.set(year, monthOfYear, dayOfMonth);
StartDate.setText(dateFormatter.format(newDate.getTime()));
}
}, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
}
#Override
public void onClick(View view) {
if(view == StartDate) {
StartDatePickerDialog.show();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_new, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Unless I'm mistaken, try removing the implements OnClickListener from your activity and replacing
StartDate.setOnClickListener(this);
with
StartDate.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(view == StartDate) {
StartDatePickerDialog.show();
}
}
});
and removing the onclick method in Start Date Picker. Basically, what implements OnClickListener does is that it can be attached to components (the EditText, in this case) which, when clicked, will be redirected to your implementation of onClick. You're replacing your Activity listener (which can be used by any component in that activity via setOnClickListener(this)) with a specific listener designed for the StartDate alone. Note how your spinners all have onItemSelectedListeners, which work on the same basic principle.
Words are hard, let me know if that doesn't make sense.
I am trying to use a spinner control that will enable the user to delete any list element.
I have an 'add' button to add elements to the list, and a 'delete' button that removes the currently-displayed item from the list.
It works as expected except when the user deletes the last item in the list. At that point, all of the list's items are deleted.
My code is as follows:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// grab our UI elements so we can manipulate them (for the Spinner)
// or add listeners to them (in the case of the buttons)
m_myDynamicSpinner = (Spinner)findViewById(R.id.dynamicSpinner);
m_addItemText = (EditText)findViewById(R.id.newSpinnerItemText);
Button addButton = (Button)findViewById(R.id.AddBtn);
Button clearButton = (Button)findViewById(R.id.ClearBtn);
// create an arrayAdapter an assign it to the spinner
m_adapterForSpinner = new ArrayAdapter(this, android.R.layout.simple_spinner_item);
((ArrayAdapter)m_adapterForSpinner).setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
m_myDynamicSpinner.setAdapter(m_adapterForSpinner);
// add listener for addButton
addButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
addNewSpinnerItem();
}
});
clearButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
clearSpinnerItems();
}
});
}
// add listener for addButton
private void addNewSpinnerItem() {
if (m_addItemText.getText().length() == 0) {
Toast.makeText(getApplicationContext(), "The textView is empty", Toast.LENGTH_LONG).show();
} else {
CharSequence textHolder = "" + m_addItemText.getText();
((ArrayAdapter) m_adapterForSpinner).add(textHolder);
}
m_addItemText.setText("");
}
private void clearSpinnerItems() {
m_myDynamicSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
Object t = m_adapterForSpinner.getItem(pos);
((ArrayAdapter) m_adapterForSpinner).remove((CharSequence) t);
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO
}
});
}
Does anyone have any ideas or suggestions on how to make this work?
The problem with your code is that the deletion is inside the onItemSelected callback, which gets called every time you are deleting an entry, thus deleting recursively until you effectively do not have any more entries to select. If you add a log inside that method:
Log.d("Spinner", "Count: " + m_adapterForSpinner.getCount());
you will see what I mean. I'm sure you can come up with more elegant code, but a quick and dirty hack is to set up a boolean flag to stop the recursion after the first deletion. See the snippet below and add the commented lines to your own code:
public class SpinnerTest extends Activity {
Spinner m_myDynamicSpinner;
EditText m_addItemText;
ArrayAdapter m_adapterForSpinner;
public static boolean cleared = false; // <--- set up a static boolean here
#Override
public void onCreate(Bundle savedInstanceState) {
// all your code unchanged
clearButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
cleared=false; // <--- nope, we did not clear the value yet
clearSpinnerItems();
}
});
}
// code unchanged
private void clearSpinnerItems() {
m_myDynamicSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
Object t = m_adapterForSpinner.getItem(pos);
Log.d("Spinner", "Count: " + m_adapterForSpinner.getCount());
if (!cleared) // <--- did I do it already?
((ArrayAdapter) m_adapterForSpinner).remove((CharSequence) t);
Log.d("Spinner", "Count: " + m_adapterForSpinner.getCount());
cleared=true; // I did it!
}
// code unchanged
i cann't understand your question.any way you can get the position of the selected item by using getSelectedItemPosition() method.