You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
6 years ago
|
package com.example.materialtest;
|
||
|
|
||
|
import android.os.Bundle;
|
||
|
import android.support.annotation.Nullable;
|
||
|
import android.support.v7.app.AppCompatActivity;
|
||
|
import android.support.v7.widget.Toolbar;
|
||
|
import android.view.Menu;
|
||
|
import android.view.MenuItem;
|
||
|
import android.widget.Toast;
|
||
|
|
||
|
public class ToolbarActivity extends AppCompatActivity {
|
||
|
@Override
|
||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||
|
super.onCreate(savedInstanceState);
|
||
|
setContentView(R.layout.activity_toolbar);
|
||
|
|
||
|
Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
|
||
|
setSupportActionBar(toolbar);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||
|
getMenuInflater().inflate(R.menu.toolbar,menu);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||
|
switch (item.getItemId()){
|
||
|
case R.id.backup:
|
||
|
Toast.makeText(this,"You clicked Backup",Toast.LENGTH_SHORT).show();
|
||
|
break;
|
||
|
case R.id.delete:
|
||
|
Toast.makeText(this,"You clicked Delete",Toast.LENGTH_SHORT).show();
|
||
|
break;
|
||
|
case R.id.settings:
|
||
|
Toast.makeText(this,"You clicked Settings",Toast.LENGTH_SHORT).show();
|
||
|
break;
|
||
|
default:
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
}
|