Rookie achieve (c) eclipse Andrews click the button progress bar forward (separate buttons and progress bar)

     Click on the following implementation is independent of the button, the progress bar moves, the progress bar reaches 100% will disappear effect.

     Search the web button and the progress bar are combined effect, I do not write. :)

 

Achieve results preview

     

     XML part of the code

 1 <!-- 进度条 -->
 2     <ProgressBar        
 3         android:id="@+id/progressBar1"
 4         style="@android:style/Widget.ProgressBar.Horizontal"
 5         android:layout_width="match_parent"
 6         android:layout_height="wrap_content"
 7         android:max="100"/>
 8     
 9     <!-- 按钮 -->
10     <Button 
11         android:id="@+id/pc"
12         android:layout_width="match_parent"
13         Android: layout_height = "wrap_content" 
14          Android: text = "Click Forward" />

 

     java part of the code

 1 public class other extends Activity{
 2     
 3     
 4     private ProgressBar horizonP;
 5     
 6     
 7     private Button pc;
 8 
 9 
10     @Override
11     protected void onCreate(Bundle savedInstanceState) {
12         // TODO Auto-generated method stub
13         super.onCreate(savedInstanceState);
14         setContentView(R.layout.other);
15         
16         
17         horizonP = (ProgressBar)findViewById(R.id.progressBar1);
18         
19         
20         pc=(Button)findViewById(R.id.pc);
21         pc.setOnClickListener(new OnClickListener() {
22             
23             @Override
24         public void onClick(View v) {
25                 
26             int progress = horizonP.getProgress()+10;
27                 horizonP.setProgress(progress);
28                 
29                 if(progress >= horizonP.getMax()){
30                     
31                     horizonP.setVisibility(View.GONE);
32                     
33                 }
34                 
35                 
36         }
37     });
38           
39         
40     }
41         
42     
43 }

 

There to help you, I recommend it - a point

Guess you like

Origin www.cnblogs.com/aslmuly/p/11620196.html