Home | History | Annotate | Download | only in app
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.example.android.supportv7.app;
     17 
     18 import android.os.Bundle;
     19 import android.view.Menu;
     20 import android.view.MenuInflater;
     21 import android.view.MenuItem;
     22 import android.widget.Toast;
     23 
     24 import androidx.appcompat.app.AppCompatActivity;
     25 import androidx.appcompat.widget.Toolbar;
     26 
     27 import com.example.android.supportv7.R;
     28 
     29 /**
     30  * This demonstrates icon tinting on menu items.
     31  */
     32 public class MenuItemIconTinting extends AppCompatActivity {
     33 
     34     @Override
     35     protected void onCreate(Bundle savedInstanceState) {
     36         super.onCreate(savedInstanceState);
     37         setContentView(R.layout.toolbar_usage);
     38 
     39         // Retrieve the Toolbar from our content view, and set it as the action bar
     40         Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
     41         setSupportActionBar(toolbar);
     42     }
     43 
     44     @Override
     45     public boolean onCreateOptionsMenu(Menu menu) {
     46         MenuInflater inflater = getMenuInflater();
     47         inflater.inflate(R.menu.menu_with_tinted_icons, menu);
     48 
     49         return true;
     50     }
     51 
     52     @Override
     53     public boolean onOptionsItemSelected(MenuItem item) {
     54         Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
     55         return true;
     56     }
     57 
     58 }
     59