当前位置:网站首页>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>
边栏推荐
猜你喜欢
AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
使用popupwindow創建对话框风格的窗口
本周小贴士#136:无序容器
麒麟信安加入宁夏商用密码协会
imageswitcher的功能和用法
Share the latest high-frequency Android interview questions, and take you to explore the Android event distribution mechanism
[video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial
Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination
SlashData开发者工具榜首等你而定!!!
策略模式 - Unity
随机推荐
Flask搭建api服务-生成API文档
浅谈 Apache Doris FE 处理查询 SQL 源码解析
阿富汗临时政府安全部队对极端组织“伊斯兰国”一处藏匿点展开军事行动
管理VDI的几个最佳实践
第二十四届中国科协湖南组委会调研课题组一行莅临麒麟信安调研考察
99% of users often make mistakes in power Bi cloud reports
2021-06-28
第1章CRM核心业务介绍
From Devops to mlops: how do it tools evolve to AI tools?
电脑无法加域,ping域名显示为公网IP,这是什么问题?怎么解决?
数值 - number(Lua)
本周小贴士#140:常量:安全习语
Establishment of solid development environment
Biped robot controlled by Arduino
Problems encountered in Jenkins' release of H5 developed by uniapp
Smart logistics platform: make overseas warehouses smarter
LeetCode 648(C#)
LeetCode 535(C#)
SIGGRAPH 2022最佳技术论文奖重磅出炉!北大陈宝权团队获荣誉提名
redis主从、哨兵主备切换搭建一步一步图解实现