android 进度条学习

package com.example.androidtest;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.content.Intent;
import android.widget.*;

public class TestActivity extends Activity  {

	private  int i=0;
	private TextView mytextview; 
	
	private RadioGroup  genderGropu = null;
	private RadioButton famalebutton =null;
	private RadioButton malebutton =null;
	
	private CheckBox swimbox =null;
	private CheckBox runbox =null;
	private CheckBox readbox =null;
	
	private ProgressBar firstBar=null;
	private ProgressBar secondBar=null;
	private Button mybutton=null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.other_activity);
	
		mytextview = (TextView)findViewById(R.id.mytextView);
		
		firstBar=(ProgressBar)findViewById(R.id.firstbar);
		secondBar=(ProgressBar)findViewById(R.id.secondbar);
		mybutton=(Button)findViewById(R.id.mybutton);
		
		mybutton.setText(R.string.progress);	
		
//		mybutton.setOnClickListener(new ButtonListener());
		
		/*			
		genderGropu = (RadioGroup)findViewById(R.id.gendergroup);
		famalebutton= (RadioButton)findViewById(R.id.female);
		malebutton= (RadioButton)findViewById(R.id.man);
		
		swimbox = (CheckBox)findViewById(R.id.swim);
		runbox =  (CheckBox)findViewById(R.id.run)	;
		readbox =  (CheckBox)findViewById(R.id.read);
		
		genderGropu.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
		{
			
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId)
			{
				// TODO Auto-generated method stub
				if(famalebutton.getId()==checkedId)
				{
				  System.out.println("female");	
				  Toast.makeText(TestActivity.this,"female被选中",Toast.LENGTH_SHORT).show();
				}
				
				else if (malebutton.getId() ==checkedId)
				{
					 System.out.println("male被选中");
					 Toast.makeText(TestActivity.this,"male被选中",Toast.LENGTH_SHORT).show();
					
				}
			}
		});
		
		swimbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() 
		{
			
			@Override
			public void onCheckedChanged(CompoundButton button, boolean ischecked) 
			{
				// TODO Auto-generated method stub
				if(ischecked)
				{
					System.out.println("游泳被选中");
					Toast.makeText(TestActivity.this,"游泳被选中",Toast.LENGTH_SHORT).show();
				}
				else
				{
					System.out.println("游泳没有被选中");
					Toast.makeText(TestActivity.this,"游泳没有被选中",Toast.LENGTH_SHORT).show();
				}
			}
		});
		
		runbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() 
		{
			
			@Override
			public void onCheckedChanged(CompoundButton button, boolean ischecked) 
			{
				// TODO Auto-generated method stub
				if(ischecked)
				{
					System.out.println("跑步被选中");
					Toast.makeText(TestActivity.this,"跑步被选中",Toast.LENGTH_SHORT).show();
				}
				else
				{
					System.out.println("跑步没有被选中");
					Toast.makeText(TestActivity.this,"跑步没有被选中",Toast.LENGTH_SHORT).show();
				}
			}
		});
		
		readbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() 
		{
			
			@Override
			public void onCheckedChanged(CompoundButton button, boolean ischecked) 
			{
				// TODO Auto-generated method stub
				if(ischecked)
				{
					System.out.println("阅读被选中");
					Toast.makeText(TestActivity.this,"阅读被选中",Toast.LENGTH_SHORT).show();
				}
				else
				{
					System.out.println("阅读没有被选中");
					Toast.makeText(TestActivity.this,"阅读没有被选中",Toast.LENGTH_SHORT).show();
				}
			}
		});
*/		
	//	Intent intent =new Intent();
	//	intent = getIntent();
		
	//	String factorone = intent.getStringExtra("one");
	//	String factortwo = intent.getStringExtra("two");
		
	//	int factoroneint = Integer.parseInt(factorone);
	//	int factortwoint = Integer.parseInt(factortwo);
		
	//	int result = factoroneint * factortwoint;
		
	//	mytextview.setText(result + "");
}
	
	public void myClick(View target)
	{			 
				 if(i == 0)
				 {
				     firstBar.setVisibility(View.VISIBLE);
				     secondBar.setVisibility(View.VISIBLE);		 
				 }
				 
				 else if(i<100)
				 {
					 firstBar.setProgress(i);
					 firstBar.setSecondaryProgress(i+10);
					 secondBar.setProgress(i);	 			 
				 }
				 
				 else
				 {
					 firstBar.setVisibility(View.GONE);
				     secondBar.setVisibility(View.GONE);	 				 
				 }	
				 i=i+10;
	}	
}
<pre name="code" class="html"><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="@color/background_color">
   
     <TextView
     android:id="@+id/mytextView"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="" /> 
     
 <!--    <RadioGroup 
         android:id="@+id/gendergroup"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         > 
    
        <RadioButton
         android:id="@+id/man"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/male"
          />   
         
        <RadioButton
         android:id="@+id/female"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/female" />   
         
        </RadioGroup>
     <CheckBox
        android:id="@+id/swim"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/swim"
         />    
     <CheckBox
         android:id="@+id/run"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/run"
         />   
     <CheckBox
         android:id="@+id/read"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/read"
         />  -->  
         
     <ProgressBar 
         android:id="@+id/firstbar"
         style="?android:attr/progressBarStyleHorizontal"
         android:layout_width="200dp"
         android:layout_height="wrap_content"
         android:visibility="gone"         
         />
     <ProgressBar 
         android:id="@+id/secondbar"
         style="?android:attr/progressBarStyle"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:visibility="gone
         />
      <Button
        android:id="@+id/mybutton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Textb"
        android:layout_marginTop="68dp" 
        android:onClick="myClick"  
        />

</LinearLayout>


 
 


你可能感兴趣的:(android 进度条学习)