I set the <button>
in activity_main.xml
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="ReturnHome"
android:text="Go Back"
android:layout_marginBottom="79dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
And now I'd like to add onBackPressed
method in AnswerActivity
public class AnswerActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_answer);
TextView textViewDisplayResult = (TextView) findViewById(R.id.text_view_display_result);
To be able to go back to previous page which is Fragment
.
Can somebody guide me step by step how to do it?
Edit:
I wrote something like this
super.onBackPressed();
Intent returnIntent = new Intent();
finish();
But it says 'variable "returnIntent" is never used'. How to fix it?