Good morning folks (GMT)
I'm still learning Java, and Android development, I know this may be a simple question, but it's been driving me crazy for a while. I've searched Google and here and couldn't find the answer.
I have a variable listViewId
, it's in my Offers
class, its current value is null
Later in the code, Once a button is pressed from a ListView
, the Variable is initialized with the ID of the ListView
, This works fine however, and opens my new Activity
page.
The issue i'm having, I need the listViewId
variable to then Toast in the New Description Page.
I've tried the offers.var Code with no luck, I've even tried a Helper
class, but when the variable is Toasted it is the null
Value and not the value of the listViewID
Kind Regards
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.offers_layout, menu);
eventslist.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
listviewIDEvents = (int) id; // takes listview ID from button pushed and stores the value to the variable listViewIDEvents
Intent myIntent = new Intent(events.this, description.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
events.this.startActivity(myIntent);
}
});
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.eventspage);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
Toast.makeText(this, "Welcome to the Description page " , Toast.LENGTH_SHORT).show();