parent
4ce209c4e9
commit
77213a7cdc
@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/drawer_layout">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<FloatingActonBar/>
|
||||
</FrameLayout>
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||
></android.support.v7.widget.Toolbar>
|
||||
</FrameLayout>
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/backup"
|
||||
android:icon="@mipmap/ic_backup"
|
||||
android:title="Backup"
|
||||
app:showAsAction="always"
|
||||
></item>
|
||||
|
||||
<item
|
||||
android:id="@+id/delete"
|
||||
android:icon="@mipmap/ic_delete"
|
||||
android:title="Delete"
|
||||
app:showAsAction="ifRoom"
|
||||
></item>
|
||||
|
||||
<item
|
||||
android:id="@+id/settings"
|
||||
android:icon="@mipmap/ic_settings"
|
||||
android:title="Settings"
|
||||
app:showAsAction="never"
|
||||
></item>
|
||||
</menu>
|
Loading…
Reference in new issue