Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在AppWidget更新期间设置自定义进度条可见性状态_Android - Fatal编程技术网

Android 如何在AppWidget更新期间设置自定义进度条可见性状态

Android 如何在AppWidget更新期间设置自定义进度条可见性状态,android,Android,你好,好吧,我不知道我又做错了什么。我想在更新Appwidget时在进度条上显示一个动画绘图,当我完成更新时,我希望进度条不可见。我知道您必须将进度条嵌入linearlayout或framelayout中,并在布局上调用remoteView的SetVisibility方法。然而,它似乎不起作用。progressbar一直可见,我不知道如何隐藏它了。我能做什么 简而言之,我有一个这样的代码来从remoteview更新progressbar,我特意在那里留下了注释,以便您知道我尝试了什么: remo

你好,好吧,我不知道我又做错了什么。我想在更新Appwidget时在进度条上显示一个动画绘图,当我完成更新时,我希望进度条不可见。我知道您必须将进度条嵌入linearlayout或framelayout中,并在布局上调用remoteView的SetVisibility方法。然而,它似乎不起作用。progressbar一直可见,我不知道如何隐藏它了。我能做什么

简而言之,我有一个这样的代码来从remoteview更新progressbar,我特意在那里留下了注释,以便您知道我尝试了什么:

remoteView.setViewVisibility(R.id.linear_progressbar_container, View.INVISIBLE);
    animateProgressBar(remoteView);


private RemoteViews animateProgressBar(RemoteViews remoteView) {
         Resources res = context.getResources();
//AnimationDrawable drawable = (AnimationDrawable)res.getDrawable(R.drawable.my_animation);
         //drawable.setOneShot(false);
         //drawable.start();

         //remoteView.setProgressBar(R.id.progress_widget_id, 0, 0, true);

         Log.d(TAG, "calling setview indeterminate");
       remoteView.setViewVisibility(R.id.linear_progressbar_container, View.INVISIBLE);

            return remoteView;
        }
在我的xml布局中,我有进度条的这一部分,它位于一个相对布局中,该布局是根目录,其中包含其他文本视图:

<LinearLayout 
        android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@id/city_id"
    android:layout_alignBaseline="@id/image_id"
    android:layout_alignTop="@id/image_id"
    android:layout_marginLeft="30dp"
    android:paddingTop="10dp"
    android:layout_centerInParent="true"
    android:id="@+id/linear_progressbar_container">    

        <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    android:id="@+id/progress_widget_id">    
        </ProgressBar>     

        </LinearLayout>

可绘制的my_animation.xml文件:

 <animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
        android:visible="false" android:oneshot="true">

     <item android:drawable="@drawable/wheel1" android:duration="50" />
     <item android:drawable="@drawable/wheel2" android:duration="50" />
     <item android:drawable="@drawable/wheel3" android:duration="50" />
     <item android:drawable="@drawable/wheel4" android:duration="50" />
     <item android:drawable="@drawable/wheel5" android:duration="50" />"

    </animation-list>

"
请帮助..:(我如何使此进度条在更新AppWidget期间和之后分别可见和不可见?感谢您的时间和所有帮助


注意:我通过服务更新所有小部件。

当经过足够的时间使其值得更新时,您应该让服务更新应用程序小部件的远程视图。

是的,我使用报警管理器通过服务更新应用程序小部件。我的意思是,我在设置适当的进度可见性b时遇到问题ar通过remoteview。它在更新时应该存在,在完成更新时不可见。