packagecom.example.administrator.progress;
importandroid.app.Activity;
importandroid.os.Bundle;
importandroid.os.Handler;
importandroid.os.Message;
importandroid.widget.ProgressBar;
publicclassMainActivityextendsActivity{
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
finalProgressBarprogressBar=(ProgressBar)findViewById(R.id.progressBar);
finalHandlerhandler=newHandler(){
@Override
publicvoidhandleMessage(Messagemsg){
super.handleMessage(msg);
progressBar.setProgress(msg.what);
}
};
finalThreadthread=newThread(){
@Override
publicvoidrun(){
super.run();
intindex=0;
intnumloop=1;
while(index<100){
try{
Thread.sleep(100);
}catch(InterruptedExceptione){
e.printStackTrace();
}
handler.sendEmptyMessage(index);
index++;
if(index==100){
while(index>1){
try{
Thread.sleep(100);
}catch(InterruptedExceptione){
e.printStackTrace();
}
handler.sendEmptyMessage(index);
index–;
}
}
}
}
};
thread.start();
}
}
xmlns:tools=”http://schemas.android.com/tools”
android:id=”@+id/activity_main”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:paddingBottom=”@dimen/activity_vertical_margin”
android:paddingLeft=”@dimen/activity_horizontal_margin”
android:paddingRight=”@dimen/activity_horizontal_margin”
android:paddingTop=”@dimen/activity_vertical_margin”
tools:context=”com.example.administrator.progress.MainActivity”>
android:id=”@+id/progressBar”
style=”@android:style/Widget.ProgressBar.Horizontal”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”/>
1、IT大王遵守相关法律法规,由于本站资源全部来源于网络程序/投稿,故资源量太大无法一一准确核实资源侵权的真实性;
2、出于传递信息之目的,故IT大王可能会误刊发损害或影响您的合法权益,请您积极与我们联系处理(所有内容不代表本站观点与立场);
3、因时间、精力有限,我们无法一一核实每一条消息的真实性,但我们会在发布之前尽最大努力来核实这些信息;
4、无论出于何种目的要求本站删除内容,您均需要提供根据国家版权局发布的示范格式
《要求删除或断开链接侵权网络内容的通知》:https://itdw.cn/ziliao/sfgs.pdf,
国家知识产权局《要求删除或断开链接侵权网络内容的通知》填写说明: http://www.ncac.gov.cn/chinacopyright/contents/12227/342400.shtml
未按照国家知识产权局格式通知一律不予处理;请按照此通知格式填写发至本站的邮箱 wl6@163.com