I have passed my resource ID through intent to another class. I then retrieve the extra from the intent and store it in an int.
Now I want to get that int to convert into a view or something so that I can use getTag()? I tried assigning it to an ImageView but kept getting NullPointer
Passed:
int resourceId = v.getId();
Intent intent = new Intent(FetchMenu.this,FetchContent.class);
intent.putExtra("ResourceId",resourceId);
startActivity(intent);
Received:
int id;
Intent callingIntent = getIntent();
int getView= callingIntent.getIntExtra("ResourceId", 1);
id = getView;
This prints to logcat:
System.out.println("Resource ID: " + id);
Logcat:"Resource ID: 2131099660"
This is giving me NullPointer:
View v = (View)findViewById(id);
String str=(String) v.getTag();
System.out.println("Tag : " + str);
Thanks
Views are from the type int. So you can put the layout as Extras in an Intent:
And then in your Activity2: