package com.example.jelica.menu;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.menu_layout, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch(item.getItemId()){
            case R.id.mailItem:
                Toast.makeText(getApplicationContext(),
                        "mailItem", Toast.LENGTH_SHORT).show();
                return true;
            case R.id.settingsitem:

                Intent intent = new Intent(this, SettingsActivity.class);
                String message = "Prosledjen string";
                intent.putExtra("poruka", message);
                startActivity(intent);

                return true;
            default:
                return super.onOptionsItemSelected(item);
        }

    }
}
