• 进度条


    一、ProgressBar控件:

    布局文件代码:

    <TextView  

        android:layout_width="fill_parent" 

        android:layout_height="wrap_content" 

        android:text="@string/hello"

        />

    <ProgressBar

    android:id="@+id/bar1"android:text="@string/hello"android:layout_width="fill_parent" 

    android:layout_height="30dp"

    style="@android:style/Widget.ProgressBar.Horizontal"

    android:visibility="gone"

     />

    <Buttonandroid:id="@+id/btn"android:text="单击增加" 

    android:layout_width="fill_parent"android:layout_height="wrap_content"/>

    Activity代码:

      btn1.setOnClickListener(new OnClickListener() {

               

               public void onClick(View v) {

                  // TODO Auto-generated method stub

                  

                  if(i==0){

                      bar.setVisibility(ProgressBar.VISIBLE);

                      

                  }else if(i<bar.getMax()){

                      bar.setProgress(i);

                      bar.setSecondaryProgress(i+10);

                  }else{

                      bar.setVisibility(ProgressBar.GONE);

                  }

                  i+=10;

               }

           });

    二、SeekBar

    Activity代码:

    public class SeekBarDemoActivity extends Activity {

        private SeekBar seekbar=null;

        /** Called when the activity is first created. */

        @Override

        public void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);

            setContentView(R.layout.main);

            seekbar=(SeekBar)findViewById(R.id.seekbar1);

            seekbar.setMax(100);

            seekbar.setOnSeekBarChangeListener(new ClickSeekBar());

        }

        class ClickSeekBar implements SeekBar.OnSeekBarChangeListener{

        @Override

        public void onProgressChanged(SeekBar seekBar, int progress,

                boolean fromUser) {

            // TODO Auto-generated method stub

            Toast.makeText(SeekBarDemoActivity.this, progress+"", Toast.LENGTH_LONG).show();

            

        }

        @Override

        public void onStartTrackingTouch(SeekBar seekBar) {

            // TODO Auto-generated method stub

            Toast.makeText(SeekBarDemoActivity.this, seekBar.getProgress()+"", Toast.LENGTH_LONG).show();

        }

        @Override

        public void onStopTrackingTouch(SeekBar seekBar) {

            // TODO Auto-generated method stub

            Toast.makeText(SeekBarDemoActivity.this, seekBar.getProgress()+"", Toast.LENGTH_LONG).show();

        }

        

        };

    }

    main.xml代码

    <?xmlversion="1.0"encoding="utf-8"?>

    <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

        android:orientation="vertical"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        >

    <TextView  

        android:layout_width="fill_parent" 

        android:layout_height="wrap_content" 

        android:text="@string/hello"

        />

    <SeekBar 

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:id="@+id/seekbar1"

        />

    </LinearLayout>

  • 相关阅读:
    #Git 21天打卡第一天 01天0526
    老徐第六期百人计划之职业发展方向&学习方向
    LR12.53安装中文补丁包,录制后回放脚本一致卡在编译的问题
    常用oracle语句整理
    LoadRunner11之批量插入SQL数据~2
    LoadRunner12之SQLServer数据库批量插入--.Net协议
    Jmeter连接Oracle数据库简单使用
    AppScan安装使用
    SQL多表连接
    [剑指Offer] 4.二维数组的查找
  • 原文地址:https://www.cnblogs.com/itfenqing/p/4429514.html
Copyright © 2020-2023  润新知