Android: Hook up game list long press menu

This commit is contained in:
Connor McLaughlin 2020-09-01 12:03:51 +10:00
parent dd0ae0fc9d
commit c5044768a8
2 changed files with 12 additions and 16 deletions

View file

@ -85,6 +85,14 @@ public class MainActivity extends AppCompatActivity {
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
int id = item.getItemId();
if (id == R.id.game_list_entry_menu_start_game) {
startEmulation(mGameList.getEntry(position).getPath(), false);
return true;
} else if (id == R.id.game_list_entry_menu_resume_game) {
startEmulation(mGameList.getEntry(position).getPath(), true);
return true;
}
return false; return false;
} }
}); });

View file

@ -1,22 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto" <menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<item <item
android:id="@+id/game_list_entry_menu_info" android:id="@+id/game_list_entry_menu_start_game"
android:title="Show Information" /> android:title="Start Game" />
<item <item
android:id="@+id/game_list_entry_menu_fast_boot" android:id="@+id/game_list_entry_menu_resume_game"
android:title="@string/settings_console_fast_boot" /> android:title="Resume Game" />
<item
android:id="@+id/game_list_entry_menu_slow_boot"
android:title="Slow Boot" />
<item
android:id="@+id/game_list_entry_menu_load_state"
android:title="Load State">
<menu>
<item android:title="Item" />
<item android:title="Item" />
</menu>
</item>
</menu> </menu>