package com.system_process.hellostudio;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.asus.amax.hellostudio.R;
import com.system_process.hellostudio.layout.FrameActivity;
import com.system_process.hellostudio.layout.RelativeActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button main_btn_rl = (Button) findViewById(R.id.relataive_btn);
        main_btn_rl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent goOtherActivity = new Intent(v.getContext(), RelativeActivity.class);
                startActivity(goOtherActivity);
            }
        });
        Button main_btn_fm = (Button) findViewById(R.id.frame_btn);
        main_btn_fm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent goOtherActivity = new Intent(v.getContext(), FrameActivity.class);
                startActivity(goOtherActivity);
            }
        });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add(0, 0, 0, "One");
        menu.add(0, 1, 2, "Two");
        menu.add(0, 2, 1, "Three");
        return super.onCreateOptionsMenu(menu);
    }

    public void sendMessage(View view) {
        String s  ="cool";
        //Toast.LENGTH_LONG表示顯示時間較長，Toast.LENGTH_SHORT則表示顯示時間較短
        Toast.makeText(view.getContext(), "這是一個Toast......", Toast.LENGTH_LONG).show();
        Log.d("HI", "sendMessage() returned: " + "this is log");
        Log.d("NiceTag", "sendMessage() returned: " + s);
    }




}

@@ -191,16 +191,46 @@
 w.Menu;%0A
+import android.view.MenuItem;%0A
 import a
@@ -1649,24 +1649,256 @@
 nu);%0A    %7D%0A%0A
+    @Override%0A    public boolean onOptionsItemSelected(MenuItem item) %7B%0A        Toast.makeText(MainActivity.this, item.getTitle(),%0A                Toast.LENGTH_SHORT).show();%0A        return super.onOptionsItemSelected(item);%0A    %7D%0A%0A
     public v

Add Toast for Menu Item