美文网首页
2018-05-08

2018-05-08

作者: 小妮詪拽 | 来源:发表于2018-05-09 10:24 被阅读0次

    滑动条..........................................................................................................................

    publicclassProgressNullActivityextendsActivity{ LinearLayout ll_progre_long; ProgressBar progressBar2; SeekBar sb_Seekbar_bar3;//对滑杆的操作privatefinalOnSeekBarChangeListener OnSeekBarChangeListener =newOnSeekBarChangeListener() {//离开滑杆@OverridepublicvoidonStopTrackingTouch(SeekBar seekBar){// TODO Auto-generated method stub// 1,得到Seekbar的进度intprogress = sb_Seekbar_bar3.getProgress();// 2,设置为progressBar1的长度progressBar2.setProgress(progress);// progressBar1.setProgress(sb_Seekbar_bar3.getProgress());//简写//判断是否到达最大值if(sb_Seekbar_bar3.getProgress()==sb_Seekbar_bar3.getMax()){ ll_progre_long.setVisibility(View.INVISIBLE);//设置为不可见占空间// ll_progre_long.setVisibility(View.GONE);//设置为不可见不占空间}else{//如果没有else滑动条的时候:滑到最大值为不可见时我又滑了回来圆形进度条还是不会显示的 ll_progre_long.setVisibility(View.VISIBLE);//设置为可见} }//---------------------(按下滑杆)--------------------- publicvoidonStartTrackingTouch(SeekBar seekBar){// TODO Auto-generated method stub}// -----------------(移动滑杆)--------------------------------@OverridepublicvoidonProgressChanged(SeekBar seekBar,intprogress,booleanfromUser){// TODO Auto-generated method stub} };@OverrideprotectedvoidonCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState); setContentView(R.layout.activity_progress_null);//获取操作ll_progre_long=(LinearLayout) findViewById(R.id.ll_progre_long); progressBar2=(ProgressBar) findViewById(R.id.progressBar2); sb_Seekbar_bar3=(SeekBar) findViewById(R.id.sb_Seekbar_bar3);//给Seekbar设置监听sb_Seekbar_bar3.setOnSeekBarChangeListener(OnSeekBarChangeListener); }}

    Activity.xml...............................................................................................................................


    <LinearLayout

    xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical">

    <LinearLayout

    android:id="@+id/ll_progre_long"android:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center">

    <ProgressBar

    android:id="@+id/progressBar1"android:layout_width="wrap_content"android:layout_height="wrap_content"/>

    <TextView

    android:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/long.........."/>

    </LinearLayout>

    <ProgressBar

    android:id="@+id/progressBar2"style="?android:attr/progressBarStyleHorizontal"android:layout_width="match_parent"android:layout_height="wrap_content"android:progress="30"/>

    <SeekBar

    android:id="@+id/sb_Seekbar_bar3"android:layout_width="match_parent"android:layout_height="wrap_content"/>

    <TextView

    android:id="@+id/textView2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/function"android:textSize="20sp"/>

    </LinearLayout>

    相关文章

      网友评论

          本文标题:2018-05-08

          本文链接:https://www.haomeiwen.com/subject/bpjwrftx.html