我为自动动画创建了自定义布局,无论它可见还是消失。这是我的代码:
public class DidiRelativeLayout extends RelativeLayout {
private AnimUtils animUtils;
private int animVisible, animGone, durVisible, durGone;
public DidiRelativeLayout(Context context) {
super(context);
animUtils = AnimUtils.getInstance(context);
}
public DidiRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
animUtils = AnimUtils.getInstance(context);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DidiRelativeLayout, 0, 0);
try {
animVisible = ta.getInteger(R.styleable.DidiRelativeLayout_anim_visible, -1);
animGone = ta.getInteger(R.styleable.DidiRelativeLayout_anim_gone, -1);
durVisible = ta.getInteger(R.styleable.DidiRelativeLayout_anim_visible_duration, AttributeConst.DEFAULT_DURATION_ANIMATION);
durGone = ta.getInteger(R.styleable.DidiRelativeLayout_anim_gone_duration, AttributeConst.DEFAULT_DURATION_ANIMATION);
} finally {
ta.recycle();
}
}
public DidiRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
animUtils = …Run Code Online (Sandbox Code Playgroud) 我正在使用JDateChooser作为Javaapp(这是我第一次使用它).当JDateChooser为空时,我希望通过以下代码来捕获错误:
if(dcs1.getDate().toString().isEmpty()){
lblOk.setText("Empty");
}else{
Date d = dcs1.getDate();
DateFormat df = new SimpleDateFormat("MM-dd-yyyy");
String t = df.format(d);
lblOk.setText(t);
}
JLabel lblOk;
JDateChooser dcs1;
Run Code Online (Sandbox Code Playgroud)
但它不起作用.Any1可以帮助我.