gpt4 book ai didi

Android Indeterminate ProgressBar 不旋转

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:21:56 24 4
gpt4 key购买 nike

很抱歉,如果之前有人问过这个问题,但我找不到这个问题的答案(我已经搜索过了!)

我已尝试按照 google/android 文档在我的应用执行冗长任务时显示并旋转不确定的进度条。

protected void readData(final String whatToFind) 
{

try
{
if (whatToFind.length() == 0)
{
adapter.notifyDataSetChanged();
return;
}


mProgress.setVisibility(View.VISIBLE);
mProgressText.setVisibility(View.VISIBLE);

m_dialog = new ProgressDialog(this);
m_dialog.setTitle("Searching...");
m_dialog.setMessage("Please wait while searching...");
m_dialog.setIndeterminate(true);
m_dialog.setCancelable(true);
m_dialog.show();

new Thread(new Runnable()
{
public void run()
{
mHandler.post(new Runnable()
{
public void run()
{

while (LotsOfWorkGoingOn)
{
// Update the progress bar
mHandler.post(new Runnable() {
public void run() {
mProgress.setProgress(m_i); /// vain attempt to make the progressbar spin
}
});

mProgress.setVisibility(View.GONE);
mProgressText.setVisibility(View.GONE);
m_dialog.hide();

}

});
}
}).start();

}
catch (Exception ex)
{
Log.e(LOGid, "Error listing items:" + ex.getStackTrace());
}

最佳答案

setProgress 仅在进度条不是 Indeterminate 时有效。

Indeterminate 表示,它没有进度量,当您不知道完成/剩余进度量以结束任务时使用。

documentation 中所述:

A progress bar can also be made indeterminate. In indeterminate mode, the progress bar shows a cyclic animation without an indication of progress. This mode is used by applications when the length of the task is unknown. The indeterminate progress bar can be either a spinning wheel or a horizontal bar.

另一方面,如果您连进度条都看不到,也许您的背景很浅?

尝试将样式属性设置为:

style="@android:style/Widget.ProgressBar.Inverse"

关于Android Indeterminate ProgressBar 不旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10376705/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com