add sorting button to the menu
This commit is contained in:
parent
fddaea76c3
commit
cd567c370b
|
@ -102,6 +102,8 @@ public class MainActivity extends SimpleActivity
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.sort:
|
||||
return true;
|
||||
case R.id.camera:
|
||||
startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
|
||||
return true;
|
||||
|
|
|
@ -124,6 +124,22 @@ public class MediaActivity extends SimpleActivity
|
|||
setTitle(dirName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_media, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.sort:
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteDirectoryIfEmpty() {
|
||||
final File file = new File(mPath);
|
||||
if (file.isDirectory() && file.listFiles().length == 0) {
|
||||
|
@ -364,7 +380,7 @@ public class MediaActivity extends SimpleActivity
|
|||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
final MenuInflater inflater = mode.getMenuInflater();
|
||||
inflater.inflate(R.menu.media_menu, menu);
|
||||
inflater.inflate(R.menu.cab_media, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<?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/sort"
|
||||
android:icon="@mipmap/sort"
|
||||
android:title="@string/sort_by"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/camera"
|
||||
android:icon="@mipmap/camera"
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?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/sort"
|
||||
android:icon="@mipmap/sort"
|
||||
android:title="@string/sort_by"
|
||||
app:showAsAction="ifRoom"/>
|
||||
</menu>
|
Loading…
Reference in New Issue