From d5aeab0fb52b0c4131afff5954afeecaa828cbe9 Mon Sep 17 00:00:00 2001 From: LinTan Date: Tue, 31 Mar 2020 18:21:42 +0800 Subject: [PATCH] =?UTF-8?q?BaseViewHolder:=201,=20=E6=B7=BB=E5=8A=A0setTex?= =?UTF-8?q?tSize()=E5=8F=8AsetBackground()=202,=20=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=BD=A2=E5=8F=82=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.gradle | 2 +- .../com/lt/library/base/BaseViewHolder.java | 36 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/config.gradle b/config.gradle index 615426a..7da069f 100644 --- a/config.gradle +++ b/config.gradle @@ -6,7 +6,7 @@ ext { minSdk : 21, targetSdk : 28, versionCode : 1, - versionName : "1.0.3", + versionName : "1.0.4", storeFile : 'C:\\SoftwareGreen\\DTP\\KeyStore\\CPY\\Android_O\\platform.keystore', storePassword: 'android', diff --git a/library/src/main/java/com/lt/library/base/BaseViewHolder.java b/library/src/main/java/com/lt/library/base/BaseViewHolder.java index d74fa53..0ccf64f 100644 --- a/library/src/main/java/com/lt/library/base/BaseViewHolder.java +++ b/library/src/main/java/com/lt/library/base/BaseViewHolder.java @@ -1,7 +1,11 @@ package com.lt.library.base; import android.graphics.drawable.Drawable; +import android.support.annotation.ColorInt; +import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.annotation.StringRes; import android.support.v7.widget.RecyclerView; import android.util.SparseArray; import android.view.View; @@ -46,9 +50,9 @@ public void setText(int viewId, CharSequence text) { view.setText(text); }//设置文本 - public void setText(int viewId, int resId) { + public void setText(int viewId, @StringRes int stringId) { TextView view = findViewById(viewId); - view.setText(resId); + view.setText(stringId); }//设置文本 public String getText(int viewId) { @@ -56,29 +60,39 @@ public String getText(int viewId) { return view.getText().toString(); }//获取文本 - public void setTextColor(int viewId, int colorId) { + public void setTextSize(int viewId, float size) { TextView view = findViewById(viewId); - view.setTextColor(colorId); + view.setTextSize(size); + }//设置文本大小 + + public void setTextColor(int viewId, @ColorInt int colorInt) { + TextView view = findViewById(viewId); + view.setTextColor(colorInt); }//设置文本颜色 - public void setImageDrawable(int viewId, Drawable resDrawable) { + public void setImageDrawable(int viewId, @Nullable Drawable drawable) { ImageView view = findViewById(viewId); - view.setImageDrawable(resDrawable); + view.setImageDrawable(drawable); }//设置图片资源 - public void setImageResource(int viewId, int resId) { + public void setImageResource(int viewId, @DrawableRes int resId) { ImageView view = findViewById(viewId); view.setImageResource(resId); }//设置图片资源 - public void setBackgroundResource(int viewId, int resId) { + public void setBackground(int viewId, @Nullable Drawable drawable) { + View view = findViewById(viewId); + view.setBackground(drawable); + }//设置背景资源 + + public void setBackgroundResource(int viewId, @DrawableRes int resId) { View view = findViewById(viewId); view.setBackgroundResource(resId); }//设置背景资源 - public void setBackgroundColor(int viewId, int colorId) { + public void setBackgroundColor(int viewId, @ColorInt int colorInt) { View view = findViewById(viewId); - view.setBackgroundColor(colorId); + view.setBackgroundColor(colorInt); }//设置背景颜色 public void setVisibility(int viewId, int visibility) { @@ -86,7 +100,7 @@ public void setVisibility(int viewId, int visibility) { view.setVisibility(visibility); }//设置显隐 - public void setOnClickListener(int viewId, View.OnClickListener listener) { + public void setOnClickListener(int viewId, @Nullable View.OnClickListener listener) { View view = findViewById(viewId); view.setOnClickListener(listener); }//设置点击事件