Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CustomAdapter extends ArrayAdapter<CustomItem> {
- private final Context context;
- private final ArrayList<CustomItem> mItemsArrayList;
- private CustomFragment mFragment;
- public CustomAdapter(Context context, ArrayList<CustomItem> itemsArrayList, CustomFragment fragment) {
- super(context, R.layout.watch_list_row, itemsArrayList);
- this.context = context;
- this.mItemsArrayList = itemsArrayList;
- this.mFragment = fragment;
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- final int pos = position;
- LayoutInflater inflater = (LayoutInflater) context
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- final View rowView = inflater.inflate(R.layout.watch_list_row, parent, false);
- final ImageView popupButton = (ImageView) rowView.findViewById(R.id.imgPopUp);
- popupButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- PopupMenu popup = new PopupMenu(context, popupButton);
- //Inflating the Popup using xml file
- popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
- popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- int i = item.getItemId();
- return onMenuItemClick(item);
- }
- });
- popup.show();//showing popup menu
- }
- });
- return rowView;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement