object menu

This commit is contained in:
Page Asgardius 2022-09-06 04:23:47 -07:00
parent 745c8fff7a
commit f1c1d7d32c
5 changed files with 38 additions and 3 deletions

View file

@ -11,6 +11,7 @@
<entry key="app/src/main/res/layout/activity_video_player.xml" value="0.1" /> <entry key="app/src/main/res/layout/activity_video_player.xml" value="0.1" />
<entry key="app/src/main/res/layout/activity_web_view.xml" value="0.17119565217391305" /> <entry key="app/src/main/res/layout/activity_web_view.xml" value="0.17119565217391305" />
<entry key="app/src/main/res/layout/list_buckets.xml" value="0.19610507246376813" /> <entry key="app/src/main/res/layout/list_buckets.xml" value="0.19610507246376813" />
<entry key="app/src/main/res/menu/object_menu.xml" value="0.20260416666666667" />
<entry key="app/src/main/res/menu/popup_menu.xml" value="0.2713541666666667" /> <entry key="app/src/main/res/menu/popup_menu.xml" value="0.2713541666666667" />
</map> </map>
</option> </option>

View file

@ -116,12 +116,12 @@ public class MainActivity extends AppCompatActivity {
@Override @Override
public void onLongClick(View view, int position) { public void onLongClick(View view, int position) {
System.out.println("Long click on "+Name.get(position).toString()); //System.out.println("Long click on "+Name.get(position).toString());
// Initializing the popup menu and giving the reference as current context // Initializing the popup menu and giving the reference as current context
PopupMenu popupMenu = new PopupMenu(MainActivity.this, recyclerView); PopupMenu popupMenu = new PopupMenu(MainActivity.this, recyclerView);
// Inflating popup menu from popup_menu.xml file // Inflating popup menu from popup_menu.xml file
popupMenu.getMenuInflater().inflate(R.menu.popup_menu, popupMenu.getMenu()); popupMenu.getMenuInflater().inflate(R.menu.account_menu, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem menuItem) { public boolean onMenuItemClick(MenuItem menuItem) {

View file

@ -8,7 +8,9 @@ import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.PopupMenu;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Toast; import android.widget.Toast;
@ -201,7 +203,30 @@ public class ObjectSelect extends AppCompatActivity {
@Override @Override
public void onLongClick(View view, int position) { public void onLongClick(View view, int position) {
System.out.println("Long click on "+Name.get(position).toString()); //System.out.println("Long click on "+Name.get(position).toString());
if (Img.get(position).equals(R.drawable.folder)) {
//go to subfolder
//explorer(Name.get(position).toString());
} else {
// Initializing the popup menu and giving the reference as current context
PopupMenu popupMenu = new PopupMenu(ObjectSelect.this, recyclerView);
// Inflating popup menu from popup_menu.xml file
popupMenu.getMenuInflater().inflate(R.menu.object_menu, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
// Toast message on menu item clicked
//Toast.makeText(MainActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
if (menuItem.getTitle() == getResources().getString(R.string.dummy_button)) {
Toast.makeText(ObjectSelect.this, "This feature is not yet implemented", Toast.LENGTH_SHORT).show();
}
return true;
}
});
// Showing the popup menu
popupMenu.show();
}
} }
})); }));
} }

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/editaccount"
android:title="@string/dummy_button" />
</menu>