zoukankan      html  css  js  c++  java
  • 进度条

    一、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>

  • 相关阅读:
    利用Continuous Testing实现Eclipse环境自动单元测试
    GWT-Dev-Plugin(即google web toolkit developer plugin)for Chrome的安装方法
    在SQL Server 2012中实现CDC for Oracle
    在SSIS 2012中使用CDC(数据变更捕获)
    SQL Server Data Tools – Business Intelligence for Visual Studio 2012安装时提示“The CPU architecture....”的解决方法
    SQL Server 2012新特性(1)T-SQL操作FileTable目录实例
    RHEL每天定时备份Oracle
    GWT-Dev-Plugin(即google web toolkit developer plugin)for firefox的下载地址
    Oracle中修改表名遇到“ORA-00054: 资源正忙, 但指定以 NOWAIT 方式获取资源, 或者超时失效”
    Oracle中序列(SEQUENCE)的使用一例
  • 原文地址:https://www.cnblogs.com/itfenqing/p/4429514.html
Copyright © 2011-2022 走看看