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.view.Menu;
203a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport android.view.MenuInflater;
213a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport android.view.MenuItem;
223a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport android.widget.Toast;
233a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
24def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikasimport androidx.appcompat.app.AppCompatActivity;
25def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikasimport androidx.appcompat.widget.Toolbar;
26def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas
273a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovimport com.example.android.supportv7.R;
283a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
293a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov/**
303a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov * This demonstrates icon tinting on menu items.
313a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov */
323a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikovpublic class MenuItemIconTinting extends AppCompatActivity {
333a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
343a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    @Override
353a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    protected void onCreate(Bundle savedInstanceState) {
363a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        super.onCreate(savedInstanceState);
373a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        setContentView(R.layout.toolbar_usage);
383a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
393a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        // Retrieve the Toolbar from our content view, and set it as the action bar
403a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
413a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        setSupportActionBar(toolbar);
423a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    }
433a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
443a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    @Override
453a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    public boolean onCreateOptionsMenu(Menu menu) {
463a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        MenuInflater inflater = getMenuInflater();
473a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        inflater.inflate(R.menu.menu_with_tinted_icons, menu);
483a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
493a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        return true;
503a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    }
513a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
523a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    @Override
533a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    public boolean onOptionsItemSelected(MenuItem item) {
543a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
553a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov        return true;
563a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov    }
573a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov
583a7c6d2009dfcf99c738d70eafe146eedf6e0ac2Kirill Grouchnikov}
59