13a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov/*
23a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov * Copyright (C) 2017 The Android Open Source Project
33a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov *
43a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov * Licensed under the Apache License, Version 2.0 (the "License");
53a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov * you may not use this file except in compliance with the License.
63a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov * You may obtain a copy of the License at
73a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov *
83a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov *      http://www.apache.org/licenses/LICENSE-2.0
93a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov *
103a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov * Unless required by applicable law or agreed to in writing, software
113a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov * distributed under the License is distributed on an "AS IS" BASIS,
123a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov * See the License for the specific language governing permissions and
143a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov * limitations under the License.
153a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov */
163a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovpackage com.example.android.supportv7.app;
173a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
183a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport android.os.Bundle;
193a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport android.support.v7.app.AppCompatActivity;
203a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport android.support.v7.widget.Toolbar;
213a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport android.view.Menu;
223a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport android.view.MenuInflater;
233a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport android.view.MenuItem;
243a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport android.widget.Toast;
253a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
263a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport com.example.android.supportv7.R;
273a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
283a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov/**
293a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov * This demonstrates icon tinting on menu items.
303a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov */
313a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovpublic class MenuItemIconTinting extends AppCompatActivity {
323a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
333a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    @Override
343a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    protected void onCreate(Bundle savedInstanceState) {
353a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        super.onCreate(savedInstanceState);
363a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        setContentView(R.layout.toolbar_usage);
373a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
383a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        // Retrieve the Toolbar from our content view, and set it as the action bar
393a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
403a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        setSupportActionBar(toolbar);
413a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    }
423a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
433a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    @Override
443a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    public boolean onCreateOptionsMenu(Menu menu) {
453a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        MenuInflater inflater = getMenuInflater();
463a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        inflater.inflate(R.menu.menu_with_tinted_icons, menu);
473a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
483a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        return true;
493a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    }
503a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
513a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    @Override
523a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    public boolean onOptionsItemSelected(MenuItem item) {
533a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
543a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        return true;
553a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    }
563a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
573a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov}
58