将刷新 ImageView 变成 ProgressBar
我正在为我的 Android 应用程序做一个自定义标题,我想要一个像 Twitter 应用程序一样的刷新按钮。 我正在使用 RelativeLayout
,我的 ImageView 是这样定义的:
<ImageView android:id="@+id/title_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_menu_refresh"
android:layout_alignParentRight="true">
</ImageView>
在我的 Activity
中,我有这样的东西:
refreshView = (ImageView) findViewById(R.id.title_refresh);
refreshView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
/* Make the refreshView turn into a progress bar. */
startService(new Intent(MyActivity.this, MyService.class));
}
}
我希望 ImageView 在我等待时变成 ProgressBar服务完成处理。 正确的方法是如何做到这一点?
I am doing a custom title for my android app and I want to have a refresh button like the Twitter app.
I am using a RelativeLayout
an my ImageView is defined by:
<ImageView android:id="@+id/title_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_menu_refresh"
android:layout_alignParentRight="true">
</ImageView>
In my Activity
I have something like this:
refreshView = (ImageView) findViewById(R.id.title_refresh);
refreshView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
/* Make the refreshView turn into a progress bar. */
startService(new Intent(MyActivity.this, MyService.class));
}
}
I would like the ImageView to turn into a ProgressBar while I wait for my service to finish processing.
How is the correct way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将进度条视图添加到
RelativeLayout
中,该视图与ImageView
与visibility:gone
重叠,然后使用setVisibilty(View. VISIBILE)
/setVisibilty(View.GONE)
在您的ImageView
和ProgressBar
上。也许
ViewSwitcher
也可以帮助您。You could add the progress bar view into the
RelativeLayout
which overlaps theImageView
withvisibility:gone
and then play withsetVisibilty(View.VISIBILE)
/setVisibilty(View.GONE)
on yourImageView
andProgressBar
.Maybe a
ViewSwitcher
could help you too.