我的应用程序中有一个弹出窗口,当单击某个按钮时它会出现不工作?这是我的代码:
我的动画.xml...
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="4000"
android:repeatCount="1"/>
</set>
================================================
创建弹出窗口
private PopupWindow showOptions(Context mcon){
try{
LayoutInflater inflater = (LayoutInflater) mcon.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.options_layout,null);
layout.setAnimation(AnimationUtils.loadAnimation(this, R.anim.myanim));
PopupWindow optionspu = new PopupWindow(layout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
optionspu.setFocusable(true);
optionspu.showAtLocation(layout, Gravity.TOP, 0, 0);
optionspu.update(0, 0, LayoutParams.WRAP_CONTENT, (int)(hei/5));
optionspu.setAnimationStyle(R.anim.myanim);
return optionspu;
}
catch (Exception e){e.printStackTrace();
return null;}
}
================================================== onClick方法...(optionsPopup 是 PopupWindow 类型的全局变量)
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.options:
optionsPopup=showOptions(this);
break;
}