설.현.아빠
제한시간 Progress Bar 만들기. 본문
main.xml
-----------------------------------------------------------------------------
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:id="@+id/progressbar_Horizontal"
android:max="100"/>
-----------------------------------------------------------------------------
코드작성
-----------------------------------------------------------------------------
int progress=0;
ProgressBar pBar;
Handler myHandle;
pBar=(ProgressBar)findViewById(R.id.progressbar_Horizontal);;
myHandle = new Handler(){
public void handleMessage(Message msg) {
progress=progress+2;
pBar.setProgress(progress);
}
};
Runnable t=new Runnable(){
public void run(){
while(progress<100){
try{
playNumber=makeRandom(0, 5);
if(!itemAni[playNumber].isRunning()){
itemAni[playNumber].start();
Log.i("BopPunch", "playNumber :"+playNumber+" start");
}
myHandle.sendMessage(myHandle.obtainMessage());
Thread.sleep(1000);
itemAni[playNumber].stop();
Log.i("BopPunch", "playNumber :"+playNumber+" stop\n-------------------\n");
}catch(Throwable e){
}
}
}
};
new Thread(t).start();
public int makeRandom(int min, int max){
Random randomizer = new Random(System.currentTimeMillis());
return randomizer.nextInt(max-min+1)+min;
}-----------------------------------------------------------------------------
'안드로이드 > Dialog' 카테고리의 다른 글
ProgressDialog 동작중 취소하기. (0) | 2011.02.11 |
---|---|
[안드로이드] 프로그레스 다이얼로그(ProgressDialog) 생성하기 [티몰스의 랩하는 프로그래머] (2) | 2011.02.11 |
ProgressDialog 2가지 종류 -> STYLE_SPINNER / STYLE_HORIZONTAL (0) | 2011.02.11 |
progressBarStyleHorizontal을 이용한 Progress Bar제작 (1) | 2011.02.11 |
Progerss Bar에 대해 잘 정리된 블로그 (0) | 2011.02.11 |