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>

  • 相关阅读:
    nginx-1.8.1的安装
    ElasticSearch 在3节点集群的启动
    The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
    sqoop导入导出对mysql再带数据库test能跑通用户自己建立的数据库则不行
    LeetCode 501. Find Mode in Binary Search Tree (找到二叉搜索树的众数)
    LeetCode 437. Path Sum III (路径之和之三)
    LeetCode 404. Sum of Left Leaves (左子叶之和)
    LeetCode 257. Binary Tree Paths (二叉树路径)
    LeetCode Questions List (LeetCode 问题列表)- Java Solutions
    LeetCode 561. Array Partition I (数组分隔之一)
  • 原文地址:https://www.cnblogs.com/itfenqing/p/4429514.html
Copyright © 2011-2022 走看看