I used setOnItemSelectedListener to specify which item is selected in a spinner, but i think it is not called. it should print "It works" when the program runs.
XML code:
<Spinner
android:id="@+id/quantity"
android:layout_width="94dp"
android:layout_height="27dp"
android:layout_x="11dp"
android:layout_y="118dp"
/>
Java code:
public class quantity extends Activity
{
Spinner quantity;
public void onCreate(Bundle savedInstanceState)
{
quantity=(Spinner)findViewById(R.id.quantity);
quantity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
{
Object item = parent.getItemAtPosition(pos);
System.out.println("it works... ");
}
public void onNothingSelected(AdapterView<?> parent)
{
}
});
}
}