当前位置:网站首页>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>

边栏推荐
- 无法链接远程redis服务器(解决办法百分百)
- Nerf: the ultimate replacement for deepfake?
- Smart logistics platform: make overseas warehouses smarter
- 请将磁盘插入“U盘(H)“的情况&无法访问 磁盘结构损坏且无法读取
- L1-028 判断素数(Lua)
- Sator a lancé le jeu web 3 "satorspace" et a lancé huobi
- toast会在程序界面上显示一个简单的提示信息
- Sator推出Web3游戏“Satorspace” ,并上线Huobi
- Flask build API service SQL configuration file
- L1-023 输出GPLT(Lua)
猜你喜欢
随机推荐
L1-028 判断素数(Lua)
跟奥巴马一起画方块(Lua)
【TPM2.0原理及应用指南】 1-3章
LeetCode 497(C#)
textSwitch文本切换器的功能和用法
第2章搭建CRM项目开发环境(数据库设计)
MySQL implements the query of merging two fields into one field
L1-025 正整数A+B(Lua)
Proxmox VE重装后,如何无损挂载原有的数据盘?
A tour of grpc:03 - proto serialization / deserialization
99%的人都不知道|私有化部署还永久免费的即时通讯软件!
Sator launched Web3 game "satorspace" and launched hoobi
简单的loading动画
Flask搭建api服务
智慧物流平台:让海外仓更聪明
Linux 安装mysql8.X超详细图文教程
阿富汗临时政府安全部队对极端组织“伊斯兰国”一处藏匿点展开军事行动
使用popupwindow創建对话框风格的窗口
【TPM2.0原理及应用指南】 12、13、14章
actionBar 导航栏学习









