반응형
안드로이드 시크바(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>
실행결과
반응형
'Language > Android' 카테고리의 다른 글
| 안드로이드(Android) TextWatcher(comma) (0) | 2013.03.08 |
|---|---|
| 안드로이드(Android),자바(JAVA) 소수점 자르기 (6) | 2013.03.07 |
| 안드로이드(Android) 메뉴 옵션 예제 (0) | 2013.02.26 |
| 안드로이드 체크박스(Android checkbox) 예제 (0) | 2013.02.26 |
| 안드로이드(Android) SDK 설치 방법 (8) | 2013.02.14 |
| 안드로이드 스피너(Android Spinner),콤보박스 (4) | 2013.02.06 |
| 안드로이드 웹뷰(Android WebView) 예제 (11) | 2013.02.06 |
| 안드로이드 프로그레스바(Android ProgressBar) (0) | 2013.01.30 |
| 안드로이드 타이머(Android Timer) (0) | 2013.01.29 |
| 안드로이드 다이얼로그(Android Dialog-확인,중립,취소 버튼) (0) | 2013.01.29 |