Compare commits

..

2 Commits
master ... dev

Author SHA1 Message Date
thibaud
7436afa797 Added ActionBar 2017-04-20 17:11:51 +02:00
thibaud
215b8cd2ca Application icon changed 2017-04-20 14:49:47 +02:00
5 changed files with 67 additions and 3 deletions

View File

@ -2,6 +2,9 @@ package com.example.diceroller;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
@ -13,7 +16,7 @@ import java.util.StringTokenizer;
* Created by thibaud on 20/04/17. * 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 TextView textResult;
private int max; private int max;
@ -41,4 +44,19 @@ public class DiceActivity extends Activity implements View.OnClickListener {
int result = rand.nextInt(max) + 1; int result = rand.nextInt(max) + 1;
this.textResult.setText(String.valueOf(result)); 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);
}
} }

View File

@ -3,6 +3,7 @@ package com.example.diceroller;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu;
import android.view.View; import android.view.View;
import android.widget.Button; 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;
}
} }

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_back"
android:icon="@android:drawable/ic_menu_revert"
android:title="@string/back"
app:showAsAction="always" />
<item
android:id="@+id/action_edit"
android:title="@string/edit"
android:icon="@android:drawable/ic_menu_edit"
app:showAsAction="ifRoom"
/>
<item
android:id="@+id/action_add"
android:title="@string/add"
android:icon="@android:drawable/ic_menu_add"
app:showAsAction="ifRoom"
/>
<item
android:id="@+id/action_delete"
android:title="@string/delete"
android:icon="@android:drawable/ic_menu_delete"
app:showAsAction="never"
/>
</menu>

View File

@ -1,9 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">DiceRoller</string>
<string name="_6_sided_dice">Dé à 6 faces</string> <string name="_6_sided_dice">Dé à 6 faces</string>
<string name="_20_sided_dice">Dé à 20 faces</string> <string name="_20_sided_dice">Dé à 20 faces</string>
<string name="x_sided_dice">faces</string> <string name="x_sided_dice">faces</string>
<string name="x">X</string> <string name="x">X</string>
<string name="roll_dice">Lancer le dé !</string> <string name="roll_dice">Lancer le dé !</string>
<string name="add">Ajouter</string>
<string name="delete">Supprimer</string>
<string name="edit">Éditer</string>
<string name="back">Retour</string>
</resources> </resources>

View File

@ -1,8 +1,12 @@
<resources> <resources>
<string name="app_name">DiceRoller</string> <string name="app_name" translatable="false">DiceRoller</string>
<string name="_6_sided_dice">6-sided dice</string> <string name="_6_sided_dice">6-sided dice</string>
<string name="_20_sided_dice">20-sided dice</string> <string name="_20_sided_dice">20-sided dice</string>
<string name="x_sided_dice">sided dice</string> <string name="x_sided_dice">sided dice</string>
<string name="x">X</string> <string name="x">X</string>
<string name="roll_dice">Roll dice !</string> <string name="roll_dice">Roll dice !</string>
<string name="edit">Edit</string>
<string name="add">Add</string>
<string name="delete">Delete</string>
<string name="back">Back</string>
</resources> </resources>