在我的应用程序中,我正在下载视频文件.我想显示下载的进度条.
如何通过AsyncTask Concept实现?
谢谢,
尼基
android asynchronous android-progressbar android-asynctask progress-bar
在游戏应用程序中,我有以下场景:
Activity开始,玩家开始在后台运行的几个游戏任务,持续时间不同.View.为此,我创建了两个Activitys和a Service,定义如下:
Service ProgressService处理ProgressBar并行线程上同时运行的几个s.
Activity WorkScreen2创建一个游戏任务,启动Servicewith中startService()传递的任务参数Bundle.
Activity ProgressScreen绑定到Service获取并显示ProgressBar正在运行的任务的s.
这两项活动在独立运行的TabHost一个第TabActivity.
我遇到的问题ServiceConnection.onServiceConnected()是永远不会调用该方法.我得到一个Java.lang.NullPointerException因为我试图调用Service应该在此方法中分配的对象的方法.见下面的代码.
我getApplicationContext().bindService()用来绑定Activity到Service因为TabSpec无法绑定Services.此方法返回true.因此,绑定是成功的.
这是Service:
public class ProgressService extends Service implements GameConstants {
public static final String BROADCAST_PROGRESS = "com.mycompany.android.mygame.progressbroadcast";
private static final long …Run Code Online (Sandbox Code Playgroud) multithreading android android-service android-progressbar android-tabhost
对于iOS我使用MBProgressHUD显示进度指示器,我喜欢它.
对于Android我使用标准进度对话框,但我想创建一些漂亮的进度条与微调在ios中.
我想加载这样的图像 
如果您有任何相关信息,请回答.
抱歉我的英语,不是我的母语.
我创建了一个单独的类,它扩展了我在整个应用程序中用于通信的AsyncTask.我的类的每个活动都使用此AsyncTask类进行通信.我想在通信进行时显示ProgressBar(活动指示符).如果我在使用通信类的活动中显示和隐藏ProgressBar,则ProgressBar会冻结,直到通信完成.有没有办法在AsyncTask类的屏幕中间显示ProgressBar,因此它不会冻结,并且用户知道后台发生了一些事情.我使用以下代码:
public class MyActivity extends Activity {
ProgressBar spinner;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_activity_layout);
spinner = (ProgressBar)findViewById(R.Id.progressbar);
spinner.setVisibility(ProgressBar.INVISIBLE);
}
protected void onResume()
{
super.onResume();
}
public void buttonClickHandler(View target){
try{
spinner.setVisibility(ProgressBar.VISIBLE);
String output = new SendRequest().execute().get();
spinner.setVisibility(ProgressBar.INVISIBLE);
}catch(Exception ex){
System.out.println("buttonClickHandler exception: "+ex);
}
}
}
Run Code Online (Sandbox Code Playgroud)
和AsyncTask类是:
public class SendRequestExample extends AsyncTask<ArrayList<String>, Void, String> {
public String result;
protected String doInBackground(ArrayList<String>... params) {
// doing communication
...
return result;
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
android android-layout android-progressbar android-asynctask android-activity
我有一个ProgressBar在更改时调用另一个函数,但每隔一段时间我的应用程序崩溃并抛出一个NoSuchMethodError.我包括我的部分代码以及堆栈跟踪,以帮助我解决问题.
我的部分Java代码:
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
ShowText();
switch(seekBar.getId()) {
case R.id.syst_bar:
ShowText();
progress = progress + 70;
tvSVal.setText(String.valueOf(progress));
if (progress == 70) {
tvSOne.setTextColor(Color.parseColor("#4E9CD2"));
tvSTwo.setTextColor(Color.WHITE);
}
else if (progress == 190) {
tvSOne.setTextColor(Color.WHITE);
tvSTwo.setTextColor(Color.parseColor("#4E9CD2"));
}
else {
tvSOne.setTextColor(Color.WHITE);
tvSTwo.setTextColor(Color.WHITE);
}
break;
case R.id.dias_bar:
ShowText();
progress = progress + 40;
tvDVal.setText(String.valueOf(progress));
if (progress == 40) {
tvDOne.setTextColor(Color.parseColor("#4E9CD2"));
tvDTwo.setTextColor(Color.WHITE);
}
else if (progress == 100) {
tvDOne.setTextColor(Color.WHITE);
tvDTwo.setTextColor(Color.parseColor("#4E9CD2"));
}
else {
tvDOne.setTextColor(Color.WHITE);
tvDTwo.setTextColor(Color.WHITE); …Run Code Online (Sandbox Code Playgroud) 是否可以像下面的图像一样进行进度条.

明星必须通过给予百分比来填补.任何帮助都会非常值得一提.谢谢.
当我的数据从启动画面中的数据库加载时,我正在使用进度条(圆圈).我使用其标签在xml中使用了进度条......但是在活动中它没有旋转...建议帮助......它有什么问题?
xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imgLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/splash" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/loading"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:text="Loading data..."
android:visibility="visible"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ProgressBar
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="92dp"
android:gravity="center"
android:indeterminateDrawable="@drawable/custom_bar" />
</RelativeLayout>
Java:
public class SplashScreen extends Activity {
static String DATABASE_NAME = "ItemDB";
static DBACESS mDbAccess = null;
public static SQLiteDatabase mDB;
public static ListItems objitem;
private static int SPLASH_TIME_OUT = 100;
private PackageManager packageManager = null;
static DataEntryClass data = …Run Code Online (Sandbox Code Playgroud) 我在res-> drawable文件夹中创建了一个名为customprogressbar.xml的XML文件:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Define the background properties like color etc -->
<item android:id="@android:id/background">
<shape>
<gradient
android:startColor="#000001"
android:centerColor="#0b131e"
android:centerY="1.0"
android:endColor="#0d1522"
android:angle="270"
/>
</shape>
</item>
<!-- Define the progress properties like start color, end color etc -->
<item android:id="@android:id/progress">
<clip>
<shape>
<gradient
android:startColor="#007A00"
android:centerColor="#007A00"
android:centerY="1.0"
android:endColor="#06101d"
android:angle="270"
/>
</shape>
</clip>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
和
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="@drawable/custom_progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)
现在我有颜色,但我需要在填充和保持之间放置指示图像.
任何的想法?
我正在使用Android的“普通”圆圈ProgressBar,如下所示:
因此,我想做的是更改此ProgressBar的颜色,厚度和拐角(带有圆角半径)。
我已经找到了一些执行此操作的示例,但是它仅适用于水平ProgressBar,但我想保留此原始ProgressBar。
非常感谢你!
android ×10
java ×2
android-xml ×1
asynchronous ×1
canvas ×1
progress-bar ×1
whatsapp ×1
xml ×1