Skip to content

Commit

Permalink
BaseViewHolder:
Browse files Browse the repository at this point in the history
1, 添加setTextSize()及setBackground()
2, 完善方法形参注解
  • Loading branch information
zuilintan committed Mar 31, 2020
1 parent fb84e07 commit d5aeab0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
36 changes: 25 additions & 11 deletions library/src/main/java/com/lt/library/base/BaseViewHolder.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -46,47 +50,57 @@ 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) {
TextView view = findViewById(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) {
View view = findViewById(viewId);
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);
}//设置点击事件
Expand Down

0 comments on commit d5aeab0

Please sign in to comment.