mardi 7 avril 2015

Load Database Intent to Spinner

I have an Intent from a column in the database. I am wondering if/how i cant put the content from the intent into a spinner? Here is the code for how/where the intent comes from


DisplayStations.java





private void PopUpAlert(final long id) {
Cursor cursor = dbHelper.getRow(id);

if (cursor.moveToFirst()){

//Preparing variables to use in message from Establishment record in Database
String ID = cursor.getString(SQL.COL_STATION_ID);
final String SName = cursor.getString(dbHelper.COL_STATION_NAME);
String SType = cursor.getString(SQL.COL_STATION_TYPE);
final String SFacility = cursor.getString(SQL.COL_FACILITIES_TYPE);
String SLocation = cursor.getString(SQL.COL_LOCATION);
String SEmail = cursor.getString(SQL.COL_EMAIL);

// building a drill down information message and displaying it in an Alert Dialog
new AlertDialog.Builder(this)
.setTitle("Facilities Review App")
.setMessage("You Selected:\n"
+ "Station ID: " + ID + "\n" + "Station Name: " + SName + "\n" +"Station Type: " + SType
+ "\n" + "Facilities: " + SFacility + "\n" + "Location: " + SLocation
+ "\n" + "Email: " + SEmail)
.setPositiveButton("Add Review", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// calling method to add a review for that particular establishment
addReviews(SName, SFacility);
}
})
.setNegativeButton("Delete", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// calling method to delete that particular establishment
deleteEstablishment(id, SName);

}


})
.setNeutralButton("List Reviews",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// calling method to list reviews for the particular establishment


}


})
.show();
}

}

private void addReviews(String SName, String SFacility) {
Intent i = new Intent(getApplicationContext(), AddReview.class);
i.putExtra("Stations", SName);
Intent a = new Intent(getApplicationContext(), AddReview.class);
a.putExtra("Stations", SFacility);
startActivity(i);
}



And here is the intent on the activity where i want the spinner to be


AddReview.java





Intent a = getIntent();
String Facility = a.getStringExtra("Stations");



Aucun commentaire:

Enregistrer un commentaire