결과화면

 

package com.example.demo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;

public class SeekBarDemo extends Activity implements SeekBar.OnSeekBarChangeListener{
 SeekBar mSeekBar;
 TextView mProgressText;
 TextView mTrackingText;
 
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.seekbar_demo);
  
  mSeekBar = (SeekBar)findViewById(R.id.seek);
  mSeekBar.setOnSeekBarChangeListener(this);
  mProgressText = (TextView)findViewById(R.id.progress);
  mTrackingText = (TextView)findViewById(R.id.tracking);
 }
 
 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch){
  mProgressText.setText(progress + " " + getString(R.string.seekbar_from_touch) + "=" + fromTouch);
 }
 
 public void onStartTrackingTouch(SeekBar seekBar){
  mTrackingText.setText(getString(R.string.seekbar_tracking_on));
 }
 
 public void onStopTrackingTouch(SeekBar seekBar){
  mTrackingText.setText(getString(R.string.seekbar_tracking_off));
 }

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <SeekBar
        android:id="@+id/seek"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:max="100"
        android:progress="50"
        android:secondaryProgress="75" />

    <TextView
        android:id="@+id/progress"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/tracking"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

//String.xml에 코드 추가~!~!

 

 <string name="seekbar_tracking_on">Tracking on</string>
    <string name="seekbar_tracking_off">Tracking off</string>
    <string name="seekbar_from_touch">from touch</string>

 

'2020년도 이전 > [WebSig] Android' 카테고리의 다른 글

ListView Demo1  (0) 2013.08.14
HScrollView Demo  (0) 2013.08.14
ProgressBar Demo3  (0) 2013.08.13
ProgressBar Demo2 -> 원형 프로그레스 바  (0) 2013.08.13
ProgressBar Demo1  (0) 2013.08.13

+ Recent posts