progress bar not working for me

Krish

What's wrong with my code i trying to populate the progress bar,but it wont't populate,

My MainActivity is

package com.example.progressbar;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.app.ProgressDialog;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public abstract class MainActivity2 extends Activity  {
int  progressStatus = 0;
int  fileSize = 0;
ProgressDialog progress;
Button button;
Handler h=new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buttonClick();
}
public void buttonClick(){
button=(Button)findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
progress=new ProgressDialog(v.getContext());
progress.setCancelable(true);
progress.setMessage("File Downloading..");
progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progress.setProgress(0);
progress.setMax(100);
progress.show();
new Thread(new Runnable() {
@Override
public void run() {
while (progressStatus<=100) {
progressStatus=doOperation();
try{
Thread.sleep(1000);
} //end of try
catch (Exception e) {
e.printStackTrace();
}// End of the Catch
h.post(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
progress.setProgress(progressStatus);
}); //end of post
} // end of while
if (progressStatus>=100)
{
try{
Thread.sleep(4000);
}catch (Exception e) {
e.printStackTrace();
}
progress.dismiss();
} 
} // end of run
}).start();
}  //end of on click method
}); //end of new on click listener
}
private int doOperation() {
while(fileSize<=10000){
++fileSize;
if(fileSize==1000){
return 10;  
}
if(fileSize==2000){
return 20;  
}
if(fileSize==3000){
return 30;  
}
if(fileSize==4000){
return 40;  
}
if(fileSize==5000){
return 50;  
}
if(fileSize==6000){
return 60;  
}
if(fileSize==7000){
return 70;  
}
if(fileSize==8000){
return 80;  
}
if(fileSize==9000){
return 90;  
}
if(fileSize==10000){
return 100; 
}
//end of while
return 100;
} // end of doOperation()
} // End of the class

Exception

09-10 09:56:12.719: D/dalvikvm(553): newInstance failed: p0 i0 [0 a1
09-10 09:56:12.770: D/AndroidRuntime(553): Shutting down VM
09-10 09:56:12.770: W/dalvikvm(553): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-10 09:56:12.890: E/AndroidRuntime(553): FATAL EXCEPTION: main
09-10 09:56:12.890: E/AndroidRuntime(553): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.progressbar/com.example.progressbar.MainActivity}: java.lang.InstantiationException: com.example.progressbar.MainActivity
09-10 09:56:12.890: E/AndroidRuntime(553):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
09-10 09:56:12.890: E/AndroidRuntime(553):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-10 09:56:12.890: E/AndroidRuntime(553):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-10 09:56:12.890: E/AndroidRuntime(553):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-10 09:56:12.890: E/AndroidRuntime(553):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 09:56:12.890: E/AndroidRuntime(553):  at android.os.Looper.loop(Looper.java:123)
09-10 09:56:12.890: E/AndroidRuntime(553):  at android.app.ActivityThread.main(ActivityThread.java:4627)
09-10 09:56:12.890: E/AndroidRuntime(553):  at java.lang.reflect.Method.invokeNative(Native Method)
09-10 09:56:12.890: E/AndroidRuntime(553):  at java.lang.reflect.Method.invoke(Method.java:521)
09-10 09:56:12.890: E/AndroidRuntime(553):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-10 09:56:12.890: E/AndroidRuntime(553):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-10 09:56:12.890: E/AndroidRuntime(553):  at dalvik.system.NativeStart.main(Native Method)
09-10 09:56:12.890: E/AndroidRuntime(553): Caused by: java.lang.InstantiationException: com.example.progressbar.MainActivity
09-10 09:56:12.890: E/AndroidRuntime(553):  at java.lang.Class.newInstanceImpl(Native Method)
09-10 09:56:12.890: E/AndroidRuntime(553):  at java.lang.Class.newInstance(Class.java:1429)
09-10 09:56:12.890: E/AndroidRuntime(553):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-10 09:56:12.890: E/AndroidRuntime(553):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
09-10 09:56:12.890: E/AndroidRuntime(553):  ... 11 more
09-10 09:59:38.939: D/dalvikvm(581): newInstance failed: p0 i0 [0 a1
09-10 09:59:38.939: D/AndroidRuntime(581): Shutting down VM
09-10 09:59:38.979: W/dalvikvm(581): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-10 09:59:39.059: E/AndroidRuntime(581): FATAL EXCEPTION: main
09-10 09:59:39.059: E/AndroidRuntime(581): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.progressbar/com.example.progressbar.MainActivity}: java.lang.InstantiationException: com.example.progressbar.MainActivity
09-10 09:59:39.059: E/AndroidRuntime(581):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
09-10 09:59:39.059: E/AndroidRuntime(581):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-10 09:59:39.059: E/AndroidRuntime(581):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-10 09:59:39.059: E/AndroidRuntime(581):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-10 09:59:39.059: E/AndroidRuntime(581):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 09:59:39.059: E/AndroidRuntime(581):  at android.os.Looper.loop(Looper.java:123)
09-10 09:59:39.059: E/AndroidRuntime(581):  at android.app.ActivityThread.main(ActivityThread.java:4627)
09-10 09:59:39.059: E/AndroidRuntime(581):  at java.lang.reflect.Method.invokeNative(Native Method)
09-10 09:59:39.059: E/AndroidRuntime(581):  at java.lang.reflect.Method.invoke(Method.java:521)
09-10 09:59:39.059: E/AndroidRuntime(581):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-10 09:59:39.059: E/AndroidRuntime(581):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-10 09:59:39.059: E/AndroidRuntime(581):  at dalvik.system.NativeStart.main(Native Method)
09-10 09:59:39.059: E/AndroidRuntime(581): Caused by: java.lang.InstantiationException: com.example.progressbar.MainActivity
09-10 09:59:39.059: E/AndroidRuntime(581):  at java.lang.Class.newInstanceImpl(Native Method)
09-10 09:59:39.059: E/AndroidRuntime(581):  at java.lang.Class.newInstance(Class.java:1429)
09-10 09:59:39.059: E/AndroidRuntime(581):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-10 09:59:39.059: E/AndroidRuntime(581):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
09-10 09:59:39.059: E/AndroidRuntime(581):  ... 11 more
09-10 10:04:39.199: I/Process(581): Sending signal. PID: 581 SIG: 9
09-10 10:09:58.549: D/dalvikvm(609): newInstance failed: p0 i0 [0 a1
09-10 10:09:58.590: D/AndroidRuntime(609): Shutting down VM
09-10 10:09:58.590: W/dalvikvm(609): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-10 10:09:58.629: E/AndroidRuntime(609): FATAL EXCEPTION: main
09-10 10:09:58.629: E/AndroidRuntime(609): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.progressbar/com.example.progressbar.MainActivity}: java.lang.InstantiationException: com.example.progressbar.MainActivity
09-10 10:09:58.629: E/AndroidRuntime(609):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
09-10 10:09:58.629: E/AndroidRuntime(609):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-10 10:09:58.629: E/AndroidRuntime(609):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-10 10:09:58.629: E/AndroidRuntime(609):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-10 10:09:58.629: E/AndroidRuntime(609):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 10:09:58.629: E/AndroidRuntime(609):  at android.os.Looper.loop(Looper.java:123)
09-10 10:09:58.629: E/AndroidRuntime(609):  at android.app.ActivityThread.main(ActivityThread.java:4627)
09-10 10:09:58.629: E/AndroidRuntime(609):  at java.lang.reflect.Method.invokeNative(Native Method)
09-10 10:09:58.629: E/AndroidRuntime(609):  at java.lang.reflect.Method.invoke(Method.java:521)
09-10 10:09:58.629: E/AndroidRuntime(609):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-10 10:09:58.629: E/AndroidRuntime(609):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-10 10:09:58.629: E/AndroidRuntime(609):  at dalvik.system.NativeStart.main(Native Method)
09-10 10:09:58.629: E/AndroidRuntime(609): Caused by: java.lang.InstantiationException: com.example.progressbar.MainActivity
09-10 10:09:58.629: E/AndroidRuntime(609):  at java.lang.Class.newInstanceImpl(Native Method)
09-10 10:09:58.629: E/AndroidRuntime(609):  at java.lang.Class.newInstance(Class.java:1429)
09-10 10:09:58.629: E/AndroidRuntime(609):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-10 10:09:58.629: E/AndroidRuntime(609):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
09-10 10:09:58.629: E/AndroidRuntime(609):  ... 11 more
09-10 10:10:05.819: I/Process(609): Sending signal. PID: 609 SIG: 9
09-10 10:17:26.139: W/KeyCharacterMap(723): No keyboard for id 0
09-10 10:17:26.150: W/KeyCharacterMap(723): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-10 10:19:15.472: W/KeyCharacterMap(781): No keyboard for id 0
09-10 10:19:15.472: W/KeyCharacterMap(781): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-10 10:43:31.709: D/dalvikvm(866): newInstance failed: p0 i0 [0 a1
09-10 10:43:31.709: D/AndroidRuntime(866): Shutting down VM
09-10 10:43:31.740: W/dalvikvm(866): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-10 10:43:31.759: E/AndroidRuntime(866): FATAL EXCEPTION: main
09-10 10:43:31.759: E/AndroidRuntime(866): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.progressbar/com.example.progressbar.MainActivity2}: java.lang.InstantiationException: com.example.progressbar.MainActivity2
09-10 10:43:31.759: E/AndroidRuntime(866):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
09-10 10:43:31.759: E/AndroidRuntime(866):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-10 10:43:31.759: E/AndroidRuntime(866):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-10 10:43:31.759: E/AndroidRuntime(866):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-10 10:43:31.759: E/AndroidRuntime(866):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 10:43:31.759: E/AndroidRuntime(866):  at android.os.Looper.loop(Looper.java:123)
09-10 10:43:31.759: E/AndroidRuntime(866):  at android.app.ActivityThread.main(ActivityThread.java:4627)
09-10 10:43:31.759: E/AndroidRuntime(866):  at java.lang.reflect.Method.invokeNative(Native Method)
09-10 10:43:31.759: E/AndroidRuntime(866):  at java.lang.reflect.Method.invoke(Method.java:521)
09-10 10:43:31.759: E/AndroidRuntime(866):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-10 10:43:31.759: E/AndroidRuntime(866):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-10 10:43:31.759: E/AndroidRuntime(866):  at dalvik.system.NativeStart.main(Native Method)
09-10 10:43:31.759: E/AndroidRuntime(866): Caused by: java.lang.InstantiationException: com.example.progressbar.MainActivity2
09-10 10:43:31.759: E/AndroidRuntime(866):  at java.lang.Class.newInstanceImpl(Native Method)
09-10 10:43:31.759: E/AndroidRuntime(866):  at java.lang.Class.newInstance(Class.java:1429)
09-10 10:43:31.759: E/AndroidRuntime(866):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-10 10:43:31.759: E/AndroidRuntime(866):  at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
09-10 10:43:31.759: E/AndroidRuntime(866):  ... 11 more
Haresh Chhelana
Just remove this keyword "abstract"

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Splash screen with progress bar

분류에서Dev

Progress bar not updating on Android

분류에서Dev

Refresh progress bar

분류에서Dev

Display Upload Progress in Modal with Bootstrap Progress Bar

분류에서Dev

Put border in empty progress bar

분류에서Dev

Using an indeterminate progress bar with a listview

분류에서Dev

Progress-bar for Ruby Upload

분류에서Dev

Progress bar at every GridView element

분류에서Dev

youtube-dl file download progress with zenity progress bar

분류에서Dev

Displaying progress bar while intent service is running

분류에서Dev

Updating progress bar asynchronously using TPL

분류에서Dev

How can I Display a Progress Bar in mplayer?

분류에서Dev

conflict betwen dplyr and progress bar (shinyIncubator)

분류에서Dev

Android custom progress bar with .gif file

분류에서Dev

implementing progress bar in wpf window with viewmodel

분류에서Dev

Custom progress bar using YouTube API

분류에서Dev

Javascript long term progress bar like Kickstarter

분류에서Dev

How to create Vertical progress bar in Bootstrap with

분류에서Dev

NoSuchMethodError when setting a custom progress bar

분류에서Dev

Linux + how to create simple Progress Bar in bash

분류에서Dev

Is there Windows 8 copy progress bar for Nautilus?

분류에서Dev

Menu bar not working in Firefox

분류에서Dev

Navigation bar jQuery not working

분류에서Dev

method overload not working for me

분류에서Dev

setOnEditorActionListener not working for me

분류에서Dev

Android show progress bar while image loading dynamically

분류에서Dev

C# How to loop through Progress Bar perfectly

분류에서Dev

How can I put progress bar component on top of the layout?

분류에서Dev

Backgroundworker doesn't update progress bar in separate window

Related 관련 기사

뜨겁다태그

보관