안드로이드 시크바(Android SeekBar) 관련 예제 입니다.

 

MainActivity.java

package com.example.h5bak_seekbar;
import android.app.Activity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;
public class MainActivity extends Activity {
    SeekBar seekbar;
    TextView tv_val;
    
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  
    seekbar=(SeekBar)findViewById(R.id.seekbar);
    tv_val=(TextView)findViewById(R.id.tv_val);
  
    seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            tv_val.setText(" 현재 값 : " + progress);
}
public void onStartTrackingTouch(SeekBar seekBar) {}
public void onStopTrackingTouch(SeekBar seekBar) {}
});
}
}



 activity_main.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
    <SeekBar android:id="@+id/seekbar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:max="100" android:progress="50">
        <TextView android:id="@+id/tv_val" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text=" 현재 값 : 50 ">
        </TextView>
    </SeekBar>
</LinearLayout>


 

실행결과

Posted by 준콩ol 준콩ol

댓글을 달아 주세요

  1. .. 2015.12.11 16:02  댓글주소  수정/삭제  댓글쓰기

    xml 파일 알파벳이 다 downcasting 되있네요..;