How would i make what i selected in the spinner appear in a textview when i choose that selection? The data would be taken from the database.
My Booking.java
package one.two;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.SimpleCursorAdapter;
import android.widget.Spinner;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;
public class Booking extends Activity
{
private DBAdapter db;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
db = new DBAdapter(this);
db.open();
setContentView(R.layout.booking);
Cursor spinnerCursor = db.getAllData();
startManagingCursor(spinnerCursor);
Spinner colourSpinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.array_arrival, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
colourSpinner.setAdapter(adapter);
colourSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
// your code here
}
});
}
}
Thank you.