当前位置:网站首页>Android Internet of things application development (smart Park) - set sensor threshold dialog interface
Android Internet of things application development (smart Park) - set sensor threshold dialog interface
2022-06-25 02:00:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
design sketch :
Customize dialog layout :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical">
<!-- Custom dialog , Linear layout horizontal direction -->
<!-- Part I title block -->
<TextView
android:id="@+id/tvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#257CFF"
android:gravity="center"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text=" Set the threshold "
android:textColor="@android:color/white"
android:textSize="18sp"/>
<!-- Set the temperature threshold -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text=" Temperature threshold setting :"
android:textColor="#6C6C6C"/>
<!-- Set the threshold -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1">
<TextView
android:id="@+id/tv_tempValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="30"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="℃"
/>
</LinearLayout>
<SeekBar
android:id="@+id/sb_temp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:max="60"
android:progress="30"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:text=" Range of values 0-60℃"
android:textColor="#6C6C6C"/>
<!-- Split line -->
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="#cccccc"></View>
<!-- Set humidity threshold -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text=" Humidity threshold setting :"
android:textColor="#6C6C6C"/>
<!-- Set the threshold -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1">
<TextView
android:id="@+id/tv_humiValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="30"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="%RH"
/>
</LinearLayout>
<SeekBar
android:id="@+id/sb_humi"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:max="100"
android:progress="30"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:text=" Range of values 0-100%RH"
android:textColor="#6C6C6C"/>
<!-- Split line -->
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="#cccccc"></View>
<!-- Set the lighting threshold -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text=" Lighting threshold setting :"
android:textColor="#6C6C6C"/>
<!-- Set the threshold -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1">
<TextView
android:id="@+id/tv_lightValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="3000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lx"/>
</LinearLayout>
<SeekBar
android:id="@+id/sb_light"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:max="10000"
android:progress="3000"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:text=" Range of values 0-10000Lx"
android:textColor="#6C6C6C"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="#cccccc"></View>
<!-- determine , Cancel button -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btn_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/white"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text=" determine "
android:textColor="#257CFF"/>
<!-- Split line -->
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#cccccc"></View>
<Button
android:id="@+id/btn_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/white"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text=" Cancel "
android:textColor="#257CFF"/>
</LinearLayout>
</LinearLayout>Custom dialog implementation class :
package com.newland.project3_3;
import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;
/**
* The set threshold dialog box appears
*/
public class SettingThresholdDialog extends Dialog {
private TextView tvTempValue,tvHumiValue,tvLightValue;
private Button btnCancel;
private Button btnConfirm;
private SeekBar sbTemp,sbHumi,sbLight;
public SettingThresholdDialog(@NonNull Context context) {
super(context,R.style.Dialog);
// Associate layout files
this.setContentView(R.layout.dialog_setting_threshold);
// Initialize components
initView();
addListener();
}
private void initView() {
sbTemp = findViewById(R.id.sb_temp);
sbHumi = findViewById(R.id.sb_humi);
sbLight = findViewById(R.id.sb_light);
tvTempValue = findViewById(R.id.tv_tempValue);
tvHumiValue = findViewById(R.id.tv_humiValue);
tvLightValue = findViewById(R.id.tv_lightValue);
btnCancel = findViewById(R.id.btn_cancel);
btnConfirm = findViewById(R.id.btn_confirm);
}
private void addListener() {
// temperature SeekBar Status change monitoring
sbTemp.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
//SeekBar Progress display to TextView On
tvTempValue.setText(String.valueOf(progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// humidity SeekBar Status change monitoring
sbHumi.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
//SeekBar Progress display to TextView On
tvHumiValue.setText(String.valueOf(progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// light SeekBar Status change monitoring
sbLight.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
//SeekBar Progress display to TextView On
tvLightValue.setText(String.valueOf(progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// Set OK click event
btnConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Dialog box disappears
SettingThresholdDialog.this.dismiss();
}
});
// Set cancel click event
btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Dialog box disappears
SettingThresholdDialog.this.dismiss();
}
});
}
}Create a dialog box in the main class and display :
package com.newland.project3_3;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create a dialog and display
SettingThresholdDialog dialog = new SettingThresholdDialog(this);
dialog.show();
}
}Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/151784.html Link to the original text :https://javaforall.cn
边栏推荐
- How to choose a regular and safe foreign exchange trading platform?
- PS5连接OPPO K9电视不支持2160P/4K
- RedisTemplate操作Redis,这一篇文章就够了(一)[通俗易懂]
- Longest continuous sequence [diffusion method + space for time]
- 实战攻防演练中的四大特点
- 动手学数据分析 数据建模和模型评估
- Sumati GameFi生态纵览,神奇世界中的元素设计
- Unity C# 网络学习(六)——FTP(二)
- Search two-dimensional matrix [clever use of bisection + record solution different from inserting bisection]
- 02 common codes for Epicor secondary development
猜你喜欢
![[leetcode] 11. Container with the most water](/img/40/8bb6506a29f8da797432fee50d3aad.png)
[leetcode] 11. Container with the most water

EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?

DDD概念复杂难懂,实际落地如何设计代码实现模型?

Hashcat 的使用

DataEase模板市场正式发布

Abnova CSV magnetic beads description in Chinese and English

带马尔科夫切换的正向随机微分方程数值格式模拟

2个NPN三极管组成的恒流电路

同一服务器两个端口不同的应用session覆盖解决方案

Constant current circuit composed of 2 NPN triodes
随机推荐
Fan benefits, JVM manual (including PDF)
(CVPR 2020) Learning Object Bounding Boxes for 3D Instance Segmentation on Point Clouds
Hashcat 的使用
mpls 笔记 part 1
Excel Chinese character to pinyin "suggestions collection"
疫情防控,居家办公,网上授课之心得 | 社区征文
RedisTemplate操作Redis,这一篇文章就够了(一)[通俗易懂]
为猪脸识别而进行自己数据集的构建、训练「建议收藏」
sql 聚合函数有哪些
Some Modest Advice for Graduate Students - by Stephen C. Stearns, Ph.D.
Elastase instructions in Chinese and English
Constant current circuit composed of 2 NPN triodes
Some Modest Advice for Graduate Students - by Stephen C. Stearns, Ph.D.
国内炒股开户正规安全的具体名单
FTP协议讲解
放养但没有完全放养(春季每日一题 2)
你知道你的ABC吗(春季每日一题 1)
EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?
MPLS notes Part 1
泰山OFFICE技术讲座:竖排时中文标点的简单研究