mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Started menu creation
This commit is contained in:
parent
554d597a0e
commit
ab905a5316
@ -3,6 +3,8 @@ package org.communiquons.android.comunic.client;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
@ -33,4 +35,36 @@ public class MainActivity extends AppCompatActivity {
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu creation
|
||||
*/
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
//Get action id
|
||||
int id = item.getItemId();
|
||||
|
||||
//Check for logout request
|
||||
if(id == R.id.action_logout){
|
||||
confirmUserLogout();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask user to confirm if he really what to sign out or not
|
||||
*/
|
||||
void confirmUserLogout(){
|
||||
Toast.makeText(this, "Do you really want to signout ???", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
11
app/src/main/res/menu/main_menu.xml
Normal file
11
app/src/main/res/menu/main_menu.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?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_logout"
|
||||
android:title="@string/main_menu_logout"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
</menu>
|
@ -9,4 +9,5 @@
|
||||
<string name="activity_login_err_invalid_credentials">The connexion couldn\'t be etablished. Please check your credentials !</string>
|
||||
<string name="err_no_internet_connection">No Internet connexion !</string>
|
||||
<string name="activity_login_err_server_response">The server sent an unexcepted response…</string>
|
||||
<string name="main_menu_logout">Sign out</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user