I have two activities.
The first activity contains a ListView widget that is populated such:
String products[] = {"Pull Restaurant names here", "Res. 1", "Res abc", "Res foo", "Res hello",
"Res xyz", "Res test", "Res test2", "Denny's"};
lv = (ListView) findViewById(R.id.listView);
// Adding items to listview
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, products);
lv.setAdapter(adapter);
Once the user selects an item from the list, I load a new activity such:
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
android.content.Intent intent = new android.content.Intent(GuestPage.this, RestaurantProfile.class);
startActivity(intent);
}
});
I want to be able to store the selected item string from the ListView into a global variable. I have a Global class that extends application, I have included the necessary name tag in my manifest. I am using something similar to:
Globals g = (Globals)getApplication();
g.setData(String s);
in order to set the Global variable.
My issue is with storing the selected ListView item because I don't know how to call it. I am not using any xml Item files to populate my ListView. How do I know which item is selected and how do I store that into my global variable?
FOR EXAMPLE: user selects "Res foo". New activity is loaded and I have a global variable to use among all activities that contains String "Res foo". Thanks.