“装载机”使用样式的按钮旁边
一般来说,我对 Java 还很陌生,所以我决定一些 SOF 输入对这个问题会有帮助 -
我有一个 Button
,当点击时,我希望在其旁边显示一个ProgressBar
。我想用一种样式来做到这一点,最好是通过 setBackgroundDrawable 发送所需的样式。
我已经在 CSS 中做过很多次了,我只是添加一个 class
,其中包含我需要的背景元素,并将文本推出一些像素。我希望我可以做类似的事情,因为我有很多 Button
对象来执行此操作。
我已经使用 JS 创建了一个我想要完成的示例。我希望这能更好地重申我的观点: http://jsfiddle.net/puPdK/3/
如果有,请告诉我更好的方法。我洗耳恭听! 谢谢。
I'm still new to Java in general, so I decided some SOF input would be helpful on this question-
I have a Button
that, when clicked, I want a ProgressBar
to show next to it. I would like to do this with a style, preferably to just send the needed style via setBackgroundDrawable
.
I've done this in CSS a number of times where I just add a class
which contains the background element I need and pushes the text out a handful of pixels. I'm hoping I can do something similar because I have a lot of Button
objects to perform this on.
I've used JS to create an example of what I want to accomplish. I'm hoping this will iterate my point better:
http://jsfiddle.net/puPdK/3/
Please feel to let me know if there is a better way. I'm all ears! Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
动画 GIF 不适用于 Android。
因此,如果您想为您的案例中的某些内容制作动画,可以使用框架动画。
或者您可以使用 ProgressBar.setInminateate 它将显示一个旋转的圆圈。并且您可以使用视图的可见性。
我们没有 HTML/CSS/JavaScript 的 javascript 部分,而 android 的 xml/stye/ 中缺少该部分?正如你所问的。
我们要看到的java代码更多的是服务器端或者后端的代码。
Animated GIF does not work with android.
so if you want to animate something in your case frameanimation can be used.
or you can use ProgressBar.setIndeterminate which will show a spinning circle. and you can use view's visibility.
we don't have the javascript part of HTML/CSS/JavaScript, which is missing in android's xml/stye/? as you have asked.
we have to see the java code more of the server-side or back-end code.
我认为执行此操作的最佳方法(据我所知)是将按钮包装在水平
LinearLayout
中。单击按钮时,我将一个new ProgressBar
作为子零添加到布局中(例如container.addView(myProgressBar, 0)
。加载完成后,我然后从我的布局container.removeViewAt(0)
中删除第一个子项。I decided the best way to do this (to my knowledge) was to wrap my button in a horizontal
LinearLayout
. When the button is clicked, I add anew ProgressBar
as child zero to my the layout (egcontainer.addView(myProgressBar, 0)
. When the loading is done, I then remove the first child from my layoutcontainer.removeViewAt(0)
. Viola.