本文主要是介绍PopupWindow动画结束后dismiss崩溃解决,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在个别机型PopupWindow动画结束后dismiss崩溃,日志:
<pre name="code" class="plain">E/libEGL(28187): call to OpenGL ES API with no current context (logged once per thread)
可能是bug,导致onAnimationEnd在错误的线程执行或者状态错误之类的,修改后问题解决:
public static PopupWindow showGainCoinPopup(Activity activity, View parent, int coinCount, final Runnable runnable){LayoutInflater li = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);View v = li.inflate(R.layout.popupwindow_get_coin, null);TextView textGetCoin = (TextView) v.findViewById(R.id.textGetCoin);textGetCoin.setText("+" + coinCount + "金币");final PopupWindow pw = new PopupWindow(v, LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);pw.setBackgroundDrawable(new BitmapDrawable());pw.setOutsideTouchable(false);pw.setFocusable(false);//pw.setAnimationStyle(R.anim.popup_enter);TranslateAnimation ani = new TranslateAnimation(0, 0, 0, -150);ani.setDuration(700);ani.setAnimationListener(new AnimationListener() {@Overridepublic void onAnimationStart(Animation animation) {}@Overridepublic void onAnimationRepeat(Animation animation) {}@Overridepublic void onAnimationEnd(Animation animation) {// 在有些手机中dismiss会崩溃new Handler().post(new Runnable() {@Overridepublic void run() {if (runnable!=null){runnable.run();}pw.dismiss();}});}});pw.showAtLocation(parent, Gravity.CENTER, 0, 0);v.startAnimation(ani);return pw;}
这篇关于PopupWindow动画结束后dismiss崩溃解决的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!