* MainActivity.java
public class MainActivity extends AppCompatActivity {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
SeekBar seekBar = findViewById(R.id.seekBar);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
textView.setText("지정된 값 : " + progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
}
* activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textView"
android:layout_marginTop="50dp"
android:textSize="30sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="지정한 값" />
</LinearLayout>
'android' 카테고리의 다른 글
Thread 사용법 (0) | 2020.02.04 |
---|---|
키패드 닫기 (0) | 2020.02.03 |
입력된 url을 WebView로 열기 (0) | 2020.02.03 |
Spinner 사용법 (0) | 2020.02.03 |
RecyclerView 리스트(문자목록, 통화목록 ..) (0) | 2020.02.03 |