Problem with Menupop

0
Hello, so this is not the first time I have been having problem with RecyclerView.ViewHolder, in this case now the following happens, My menu has 2 buttons I'm trying to get the click with switch (item.getItemId ()) I really do not know if this is the right one when I try to do something simple like opening an activity I can not because it asks to put the ViewH as, not Static, there does not appear any more apparent error when sneaking the app soon appears error java.lang.NoSuchMethodException: class android.view.View ... I tried to put it in a separate class and then there were other problems that did not work out as well. I do not know if I was clear enough with the question if not, ask me that I add something.

At the information level, I'm not going to work by opening an activity, I'll do that How do I edit a child on firebase? and delete childs.

public class BloviewHolderr extends  RecyclerView.ViewHolder{

    View mView;
    ImageButton mMenuPopup;
    Context mContext;
    private DatabaseReference mDatabase1;
    public BloviewHolderr(View itemView) {
        super(itemView);

        mView = itemView;
        mMenuPopup = (ImageButton) mView.findViewById(R.id.menuComentario);

        mMenuPopup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mContext = mView.getContext();
                PopupMenu popup = new PopupMenu(mContext, mMenuPopup);
                //Inflando o popup usando o arquivo xml
                popup.getMenuInflater().inflate(R.menu.menu_comentarioo, popup.getMenu());

                //Resgata o item clicado e mostra em um Toast
                popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    public boolean onMenuItemClick(MenuItem item) {
                        switch (item.getItemId()) {
                            case R.id.apagar:
                                Intent singleBlogIntent = new Intent (Comentarios.this, FloatChat.class);
                                startActivity(singleBlogIntent);
                        // read the listItemPosition here
                                // read the listItemPositionForPopupMenu here
                                return true;
                            default:
                                return false;
                        }
                    }});

                popup.show();;
                }
            });
        }

    
asked by anonymous 25.02.2017 / 19:13

1 answer

1

I do not see any problem with the click in the item relative to PopupMenu . Use the context in which view is displayed. Then you can modify your Intent by entering mContext this way:

Intent singleBlogIntent = new Intent (mContext, FloatChat.class);
mContext.startActivity(singleBlogIntent);
    
25.02.2017 / 21:06