1 /*
2  * Copyright 2019 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.androidx.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.androidx.R;
28 
29 /**
30  * This demonstrates usage of a tall Toolbar.
31  */
32 public class ToolbarTall extends AppCompatActivity {
33 
34     @Override
onCreate(Bundle savedInstanceState)35     protected void onCreate(Bundle savedInstanceState) {
36         super.onCreate(savedInstanceState);
37         setContentView(R.layout.toolbar_tall);
38 
39         // Retrieve the Toolbar from our content view, and set it as the action bar
40         Toolbar toolbar = findViewById(R.id.toolbar);
41         setSupportActionBar(toolbar);
42     }
43 
44     @Override
onCreateOptionsMenu(Menu menu)45     public boolean onCreateOptionsMenu(Menu menu) {
46         MenuInflater inflater = getMenuInflater();
47         inflater.inflate(R.menu.single_action, menu);
48 
49         return true;
50     }
51 
52     @Override
onOptionsItemSelected(MenuItem item)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