package com.bgstation0.android.sample.menuitem_;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;

public class MainActivity extends Activity {

	// otB[hÌè`.
	Context mContext = null;	// mContextðnullÉú».
		
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mContext = this;	// mContextÉthisðZbg.
    }
    
    // j[ªì¬³ê½.
    @Override
    public boolean onCreateOptionsMenu(Menu menu){
    	
    	// j[Ìì¬
    	getMenuInflater().inflate(R.menu.main, menu);	// getMenuInflaterÅMenuItemðæ¾µ, »ÌÜÜinflateÅwè³ê½R.menu.mainð³Émenuðì¬.
    	ActionBar actionBar = getActionBar();	// getActionBarÅactionBarðæ¾.
    	actionBar.setDisplayShowTitleEnabled(false);	// actionBar.setDisplayShowTitleEnabledðfalseÉµÄ^Cgðñ\¦.
    	actionBar.setDisplayShowHomeEnabled(false);	// actionBar.setDisplayShowHomeEnabledðfalseÉµÄACRàñ\¦.
    	
    	// ANVr[Ìæ¾.
    	MenuItem menuItemSearch = menu.findItem(R.id.menu_item_search_layout);	// menuItemSearchÌæ¾.
    	LinearLayout searchRoot = (LinearLayout)menuItemSearch.getActionView();	// getActionViewÅsearchRootæ¾.
    	Button closeButton = (Button)searchRoot.findViewById(R.id.search_close_button);	// closeButtonæ¾.
    	closeButton.setOnClickListener(new OnClickListener(){
    		@Override
    		public void onClick(View v){
    			Toast.makeText(mContext, "Close Clicked!", Toast.LENGTH_LONG).show();	// "Close Clicked!"ð\¦.
    		}
    	});
    	return true;
    	
    }
    
}