From 7436afa79710bee97698256fe25edb921289e0c9 Mon Sep 17 00:00:00 2001 From: thibaud Date: Thu, 20 Apr 2017 17:03:03 +0200 Subject: [PATCH] Added ActionBar --- app/src/main/AndroidManifest.xml | 1 - .../com/example/diceroller/DiceActivity.java | 20 +++++++++++- .../com/example/diceroller/MainActivity.java | 8 +++++ app/src/main/res/menu/main_menu.xml | 31 +++++++++++++++++++ app/src/main/res/values-fr/strings.xml | 5 ++- app/src/main/res/values/strings.xml | 6 +++- 6 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/menu/main_menu.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f090282..524a4a5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,7 +6,6 @@ android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" - android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> diff --git a/app/src/main/java/com/example/diceroller/DiceActivity.java b/app/src/main/java/com/example/diceroller/DiceActivity.java index aefb9cb..7e4ca2b 100644 --- a/app/src/main/java/com/example/diceroller/DiceActivity.java +++ b/app/src/main/java/com/example/diceroller/DiceActivity.java @@ -2,6 +2,9 @@ package com.example.diceroller; import android.app.Activity; import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.TextView; @@ -13,7 +16,7 @@ import java.util.StringTokenizer; * Created by thibaud on 20/04/17. */ -public class DiceActivity extends Activity implements View.OnClickListener { +public class DiceActivity extends AppCompatActivity implements View.OnClickListener { private TextView textResult; private int max; @@ -41,4 +44,19 @@ public class DiceActivity extends Activity implements View.OnClickListener { int result = rand.nextInt(max) + 1; this.textResult.setText(String.valueOf(result)); } + + @Override + public boolean onCreateOptionsMenu(Menu menu){ + getMenuInflater().inflate(R.menu.main_menu, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item){ + switch (item.getItemId()){ + case R.id.action_back: + return true; + } + return super.onOptionsItemSelected(item); + } } diff --git a/app/src/main/java/com/example/diceroller/MainActivity.java b/app/src/main/java/com/example/diceroller/MainActivity.java index 9c9b7cc..c4a86ce 100644 --- a/app/src/main/java/com/example/diceroller/MainActivity.java +++ b/app/src/main/java/com/example/diceroller/MainActivity.java @@ -3,6 +3,7 @@ package com.example.diceroller; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.view.Menu; import android.view.View; import android.widget.Button; @@ -33,4 +34,11 @@ public class MainActivity extends AppCompatActivity { } }); } + + + @Override + public boolean onCreateOptionsMenu(Menu menu){ + getMenuInflater().inflate(R.menu.main_menu, menu); + return true; + } } diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml new file mode 100644 index 0000000..f9e6fd6 --- /dev/null +++ b/app/src/main/res/menu/main_menu.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 615d63c..1bcc4bc 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -1,9 +1,12 @@ - DiceRoller Dé à 6 faces Dé à 20 faces faces X Lancer le dé ! + Ajouter + Supprimer + Éditer + Retour \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 24aa97e..4798594 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,8 +1,12 @@ - DiceRoller + DiceRoller 6-sided dice 20-sided dice sided dice X Roll dice ! + Edit + Add + Delete + Back