Added back button on game activity
This commit is contained in:
parent
fb2d81550c
commit
e8c2504a33
|
@ -33,6 +33,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
@ -40,6 +41,7 @@ import android.widget.TextView;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import butterknife.BindView;
|
||||
|
@ -79,6 +81,10 @@ public class TriviaGameActivity extends BaseActivity
|
|||
setContentView(R.layout.activity_trivia_game);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null)
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
this.game = (TriviaGame) savedInstanceState.getSerializable(STATE_TRIVIA_GAME);
|
||||
} else {
|
||||
|
@ -118,6 +124,17 @@ public class TriviaGameActivity extends BaseActivity
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void onTriviaQuestionsDownloaded(String json) {
|
||||
if (json == null) {
|
||||
onNetworkError();
|
||||
|
|
Loading…
Reference in New Issue