My code flow is:
Reports => ReportsType
Reports is having 3 items and on click of each item, I am starting the activity ReportsType
passing the tag with the name name
in the intent to distinguish which item was clicked.
The problem is OnCreate method is called only once, so heading is always set to what item was clicked in the starting.
public void onCreate(Bundle si)
{
Intent intent = getIntent();
heading = intent.getExtras().getString("name"); //this tells which item was clicked.
TextView heading_txt = (TextView) findViewById(R.id.heading);
heading_txt.setText(heading);
}
I tried to put this code at onResume()
call because it is called everytime the activity resumes. But still the getIntent()
is giving the old name
value set from previous item.
How to get the current clicked item intent value in the other activity?
UPDATE:
Reports activity code:
public void showReport(View v) {
String tag = v.getTag().toString();
Intent i5 = new Intent(this, ReportsType.class);
i5.putExtra("name", tag);
startActivity(i5);
}
Where showReport()
method is called each item you click any of the three items.
UPDATE:
goBackReport code
public void goBackReport(View v)
{
Intent intent = new Intent(ReportsType.this, Reports.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
finish();
}
XML button view
<Button
android:id="@+id/entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_blue_xml"
android:clickable="true"
android:padding="8dp"
android:onClick="goBackReport"
android:text="Back"
android:textColor="#ffffff"
android:textSize="15dp" />