Popup Menu in custom ListView

前端 未结 7 1356
礼貌的吻别
礼貌的吻别 2020-12-05 11:44

What I want to achieve:

I have a custom ListView adapter. To each Listitem I want to add a popup menu, pretty similar to the ListView in the current Google Play appl

相关标签:
7条回答
  • 2020-12-05 12:27

    I fixed a similar error just by passing as parameter a static activity. For example:

    static AppCompatActivity sActivity;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        sActivity = this;
    
    yourLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            PopupMenu popup = new PopupMenu(sActivity, v);
            MenuInflater inflater = popup.getMenuInflater();
            inflater.inflate(R.menu.my_popup_menu, popup.getMenu());
            popup.show();
            }
       });
    }
    

    Also, you problem might be this one: Issue 152141

    Hopefully it will help you, respecting the android.support.v7.widget.PopupMenu import.

    Regards.

    0 讨论(0)
提交回复
热议问题