app/src/main/java/me/zhanghai/android/douya/ui/AutoGoneTextView.java
(完整代码) 1KB/*
* Copyright (c) 2015 Zhang Hai <Dreaming.in.Code.ZH@Gmail.com>
* All Rights Reserved.
*/
package me.zhanghai.android.douya.ui;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.TextView;
import me.zhanghai.android.douya.util.ViewUtils;
/**
* TextView that automatically sets its visibility to View.GONE when empty.
*/
public class AutoGoneTextView extends TextView {
public AutoGoneTextView(Context context) {
super(context);
}
public AutoGoneTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public AutoGoneTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public AutoGoneTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public void setText(CharSequence text, BufferType type) {
super.setText(text, type);
ViewUtils.setVisibleOrGone(this, !TextUtils.isEmpty(text));
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
