Activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<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/volume"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Now volume : 50" />
</LinearLayout>
MainActivity.java
package com.example.seekbar;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.SeekBar;
import android.widget.TextView;
public class MainActivity extends Activity {
SeekBar mSeekBar;
TextView mVolume;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSeekBar = (SeekBar)findViewById(R.id.seekbar);
mVolume = (TextView)findViewById(R.id.volume);
mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
mVolume.setText("Now volume : " + progress);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
'Android' 카테고리의 다른 글
날짜와 시간 - DatePicker (0) | 2013.04.02 |
---|---|
래이팅바(RatingBar) (0) | 2013.04.02 |
프로그레스 바 (ProgressBar) 실습2 (0) | 2013.04.02 |
프로그레스 바 (ProgressBar) 실습 (0) | 2013.04.02 |
어댑터뷰 - 갤러리 (0) | 2013.04.01 |