android:java.lang.NoSuchMethodError: android.widget.PopupWindow.showAsDropDown

This version occurs when the android version is <16. The original call: public void showAsDropDown(View anchor, int xoff, int yoff, int gravity) should be changed to public void showAsDropDown(View anchor, int xoff, int yoff). That is, remove the last gravity parameter:

Roughly written:

 if (Build.VERSION.SDK_INT >= 16)
            dialog.showAsDropDown(getSupportActionBar().getCustomView(), 500, 0, Gravity.END);
        else
            dialog.showAsDropDown(getSupportActionBar().getCustomView(), 500, 0);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324685336&siteId=291194637