当前位置:网站首页>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
边栏推荐
- TSDB在民机行业中的应用
- Poj3669 meteor shower (BFS pretreatment)
- Multimodal emotion recognition_ Research on emotion recognition based on multimodal fusion
- Day 04 - file IO
- Fan benefits, JVM manual (including PDF)
- 02 common codes for Epicor secondary development
- Chrysanthemum chain (winter vacation daily question 39)
- How to choose a regular and safe foreign exchange trading platform?
- Chinese address and English address
- Longest continuous sequence [diffusion method + space for time]
猜你喜欢

Abnova 5-methylcytosine polyclonal antibody

第04天-文件IO

Intégration de la plate - forme de test continu open source de metersphere avec Alibaba Cloud Effect devops

明日考试 最后一天如何备考?二造考点攻略全整理

内网学习笔记(5)

EasyCVR平台EHOME协议接入,视频播放出现断流是什么原因?

Fatigue liée à l'examen du marché secondaire des médicaments innovants: succès clinique de la phase III et approbation du produit

創新藥二級市場審餅疲勞:三期臨床成功、產品獲批也不管用了

Application session coverage solutions with different ports on the same server

多模态数据也能进行MAE?伯克利&谷歌提出M3AE,在图像和文本数据上进行MAE!最优掩蔽率可达75%,显著高于BERT的15%
随机推荐
EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?
SQL aggregate function handling null [easy to understand]
Elastase instructions in Chinese and English
Transformers 库的基本使用
菊花链(寒假每日一题 39)
[leetcode] 11. Container with the most water
Redistemplate operates redis. This article is enough (I) [easy to understand]
MPLS notes Part 1
实验5 8254定时/计数器应用实验【微机原理】【实验】
Redis and jedis
动手学数据分析 数据建模和模型评估
Chinese address and English address
监听 Markdown 文件并热更新 Next.js 页面
Integration of metersphere open source continuous testing platform and Alibaba cloud cloud cloud efficient Devops
An Chaoyun: "one cloud with multiple cores" supports the implementation of the national information innovation government cloud
门店无线音箱造假?索尼回应:产品预留了有线连接接口 复杂场景下可以使用
Listen to the markdown file and hot update next JS page
谷歌浏览器控制台 f12怎么设置成中文/英文 切换方法,一定要看到最后!!!
MOS tube related knowledge
How to open a stock account? Is it safe to open a mobile account?