Problem with Menupop

Asked

Viewed 19 times

0

Hello, so it’s no longer the first time I’ve been having trouble with Recyclerview.Viewholder, in this case now happens the following, My menu has 2 buttons I’m trying to catch the click with switch (item.getItemId()) I really don’t know if this is the right more when I try to do something simple like open an activity I can’t get since it asks to put the Viewh as, not Static, then no apparent error appears more when I run the app soon appears the error java.lang.Nosuchmethodexception: class android.view.View ... I tried to put in a separate class but then came other problems that didn’t solve either. I don’t know if I was clear enough with the question if not, ask me if I add something.

At information level, I’m not going to work opening Victoria, I’ll do it How I Edit a Child in firebase? and erase 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();;
                }
            });
        }

inserir a descrição da imagem aqui

  • It has as you put your menu_comentarioo.xlm?

  • how it works to put some action in the click, I was trying to open an activity and could not, then tried to do a simple action in firebase also could not

  • I don’t think clicking on the way I’m doing public Boolean onMenuItemClick(Menuitem item) { switch (item.getItemId()) { case R.id.delete:

  • From what I can see, the click on the item is working perfectly. Check it out: I took the Intent and put a Toast https://drive.google.com/open?id=0BxfzFAS7MTC0bktGNmdFNVRVOHM

  • then it must be the intention since even the Toast I could not use

  • when I try to use an intention that opens an activity Activity appears highlighted and when I try to solve apprece to take out Static(public Static class Bloviewholderr extends Recyclerview.Viewholder{) so if I do this error activity after (java.lang.Nosuchmethodexception: class android.view.View)

Show 2 more comments

1 answer

1


I don’t see any problem with the click in the item in relation to the PopupMenu. Use the context in which the view is being shown. Then you can modify your Intent inserting the mContext in this way:

Intent singleBlogIntent = new Intent (mContext, FloatChat.class);
mContext.startActivity(singleBlogIntent);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.