SeekBar 说明
我注意到很多人都在寻找同一问题的答案,但他们总是有不同的结果并且不完整,我希望有人能提供尽可能简单的解释来帮助所有用户。
我现在将开始编写 android 程序并需要帮助,如下所示:
我有一个 id = value 的 TextView 和一个 id=seekbar 的 SeekBar。
想要搜索栏 0-200 比 1 合 1,在 TextView 中显示值。 为了纠正灵敏度问题,想知道如何放置两个按钮 + 和 - 来增加或减少 a。
我代表我大学的全体同学感谢你们。
I noticed that many people looking for the answer to same question however they always have different results and incomplete, I would like help from someone explain as simple as possible to help all users.
I will start programming an android now and wanted help, is as follows:
I have a TextView with id = value
and one SeekBar with id = seekbar.
Wanted the seekbar 0-200 than 1 in 1, showing the values in TextView.
And to correct the problem of sensitivity was wondering how to put two buttons + and - to increment or decrement a.
I thank you on behalf of all my college class.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要监听搜索位置的变化,请使用
on + 和 - 按钮单击实现 onClickListener,并在 onClick 方法中编写
To listen seek position changes, use
on + and - Button click implement onClickListener, and in onClick method, write
假设这是您想要的 UI(非常糟糕的 ASCII 艺术)
实现此目的所需的布局(伪代码)
进度条监听器(伪代码)
按钮监听器(伪代码)
Assume this is the UI you want (pretty bad ASCII art)
Layout required to achieve this (pseudocode)
Listener for Progress Bar (pseudocode)
Listener for buttons (pseudocode)
在这里,您不需要两个不同的按钮来执行增量和增量操作。减量运算。
只需在这里设置开始和结束位置并进行操作,它就会按照您的需要执行。
试试这个代码...
Here you dont need two diffrent buttons to perform increment & decrement operations.
Just set start and end positions here and do the operations, it will perform as like for your need.
Try this code...
在提出这样的一般性问题之前,您应该先阅读文档。确实,我想用通俗的语言来回答这个问题。只需将搜索栏视为一个简单的传感器即可。它可以触发像 onProgressChanged() 这样的事件。这意味着,当搜索栏进度发生变化时,搜索栏的界面可以告诉我们。这样,我们就可以在Android提供的回调中进行一些操作。因此,请查看代码,看看这就是您要寻找的内容。这是我为这个问题创建的测试应用程序。
这是用于此应用程序的 XML
如果您对此代码有任何疑问,请随时询问。
顺便说一句,这不是代码生成论坛!看来我违反了 SOF 条款之一......:)
You should have read the documentation before asking such a generic question. Indeed, I would like to answer to this question in layman terms. Just think about seekbar as a simple sensor. It can fire events like onProgressChanged(). Means, the interface for seekbar can tell us when the seekbar progress is changed. Thus, we can do some operations inside the callbacks provided by Android. So take a look at the code and see this is what you are looking for. This is a test application I have created for this question.
And this is the XML used for this application
Feel free to ask if you have any doubt on this code.
By the way, this is not a code generating forum! Seems like I'm breaking one of the SOF terms... :)