当前位置:网站首页>Function and usage of numberpick
Function and usage of numberpick
2022-07-07 17:36:00 【XLMN】
Numberpick The function and usage of
Value selector , It is used for users to enter values , You can enter values through the keyboard , You can also drag to select values
public class MainActivity extends Activity {
NumberPicker np1, np2;
// Define the minimum value , Initial value of maximum value
int minfraction = 140, maxfraction = 150;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.numberpicket);
np1 = findViewById(R.id.numberpicket);
np1.setMaxValue(150);
np1.setMinValue(140);
// Set up np1 The current value of the
np1.setValue(minfraction);
// Add listener
np1.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
// When numberPICKET When things change , Will stimulate the method
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
minfraction = newVal;
showSelectedPrice();
}
});
np2 = findViewById(R.id.numberpicket01);
np2.setMinValue(145);
np2.setMaxValue(150);
// set currency
np2.setValue(maxfraction);
// Add listener
np2.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
minfraction = newVal;
showSelectedPrice();
}
});
}
private void showSelectedPrice() {
Toast.makeText(this, " Your lowest score in a single subject is " + minfraction + " Your highest score in a single subject is " + maxfraction, Toast.LENGTH_LONG).show();
}
}
<?xml version="1.0" encoding="utf-8"?><TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text=" Minimum score of single subject " />
<NumberPicker
android:id="@+id/numberpicket"
android:layout_width="match_parent"
android:layout_height="150dp"
android:focusable="true"
android:focusableInTouchMode="true" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text=" The maximum score of a single subject "></TextView>
<NumberPicker
android:id="@+id/numberpicket01"
android:layout_width="match_parent"
android:layout_height="150dp"
android:focusable="true"
android:focusableInTouchMode="true" />
</TableRow>

边栏推荐
- 【TPM2.0原理及应用指南】 9、10、11章
- Mrs offline data analysis: process OBS data through Flink job
- Proxmox VE重装后,如何无损挂载原有的数据盘?
- MRS离线数据分析:通过Flink作业处理OBS数据
- serachview的功能和用法
- ViewSwitcher的功能和用法
- [source code interpretation] | source code interpretation of livelistenerbus
- 到底有多二(Lua)
- Sator推出Web3遊戲“Satorspace” ,並上線Huobi
- LeetCode 497(C#)
猜你喜欢
随机推荐
mysql官网下载:Linux的mysql8.x版本(图文详解)
本周小贴士#134:make_unique与私有构造函数
Flash build API service
viewflipper的功能和用法
What is cloud computing?
The mail server is listed in the blacklist. How to unblock it quickly?
【网络攻防原理与技术】第7章:口令攻击技术 第8章:网络监听技术
第3章业务功能开发(用户访问项目)
centos7安装mysql笔记
redis主从、哨兵主备切换搭建一步一步图解实现
【网络攻防原理与技术】第4章:网络扫描技术
Sator推出Web3遊戲“Satorspace” ,並上線Huobi
智慧物流平台:让海外仓更聪明
Linux 安装mysql8.X超详细图文教程
网络攻防复习篇
请将磁盘插入“U盘(H)“的情况&无法访问 磁盘结构损坏且无法读取
rpcms获取指定分类下的文章的方法
L1-028 判断素数(Lua)
浅谈 Apache Doris FE 处理查询 SQL 源码解析
The top of slashdata developer tool is up to you!!!








