mirror of
https://github.com/niushuai233/DevControl.git
synced 2024-10-27 22:43:20 +08:00
fix: 设置回显数据
This commit is contained in:
parent
7f5dbacc10
commit
79f922d1df
@ -4,8 +4,11 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
|
||||
public class UiUtil {
|
||||
|
||||
public static int dip2px(Context context, float dipValue) {
|
||||
@ -17,4 +20,15 @@ public class UiUtil {
|
||||
public static String getTextViewTextById(Activity activity, int id) {
|
||||
return ((TextView) activity.findViewById(id)).getText().toString();
|
||||
}
|
||||
|
||||
public static void setTextViewTextById(Activity activity, int id, String text) {
|
||||
((TextView) activity.findViewById(id)).setText(text);
|
||||
}
|
||||
|
||||
public static void setImageResource(Activity activity, int id, int resId) {
|
||||
((ImageView) activity.findViewById(id)).setImageResource(resId);
|
||||
}
|
||||
public static void setAppImageCompatResource(Activity activity, int id, int resId) {
|
||||
((AppCompatImageView) activity.findViewById(id)).setImageResource(resId);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cc.niushuai.project.devcontrol.ui.powerswitch;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@ -10,6 +11,7 @@ import cc.niushuai.project.devcontrol.R;
|
||||
import cc.niushuai.project.devcontrol.base.ui.BaseActivity;
|
||||
import cc.niushuai.project.devcontrol.base.util.GlobalVariables;
|
||||
import cc.niushuai.project.devcontrol.base.util.ToastUtil;
|
||||
import cc.niushuai.project.devcontrol.base.util.UiUtil;
|
||||
import cc.niushuai.project.devcontrol.databinding.ActivityPowerSwitchSetParamBinding;
|
||||
|
||||
|
||||
@ -34,8 +36,27 @@ public class PowerSwitchSetParamActivity extends BaseActivity {
|
||||
|
||||
this.setTitle(null, getString(R.string.power_switch_set_paramSet), null, R.drawable.ic_confrim_32);
|
||||
|
||||
this.echoData();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 回显数据
|
||||
*
|
||||
* @author niushuai
|
||||
* @date: 2022/10/25 9:01
|
||||
*/
|
||||
private void echoData() {
|
||||
|
||||
UiUtil.setTextViewTextById(this, R.id.device_add_name, device.getDeviceName());
|
||||
UiUtil.setTextViewTextById(this, R.id.device_add_param_program, device.getCommandPath());
|
||||
UiUtil.setTextViewTextById(this, R.id.device_add_param_status, device.getCommandStatus());
|
||||
UiUtil.setTextViewTextById(this, R.id.device_add_param_open, device.getCommandOpen());
|
||||
UiUtil.setTextViewTextById(this, R.id.device_add_param_close, device.getCommandClose());
|
||||
UiUtil.setTextViewTextById(this, R.id.device_add_param_remark, device.getRemark());
|
||||
|
||||
UiUtil.setAppImageCompatResource(this, R.id.device_add_select_icon, device.getIconId());
|
||||
}
|
||||
@Override
|
||||
protected void addListener() {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user