SeekBarActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_seek_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.bhaumik.programmingstudy.SeekBarActivity">
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:id="@+id/seekbar"
android:max="100"/>
</LinearLayout>
SeekBarActivity.java
package com.bhaumik.programmingstudy;
import android.hardware.SensorEventListener;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.SeekBar;
public class SeekBarActivity extends AppCompatActivity {
SeekBar seekBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seek_bar);
seekBar = (SeekBar) findViewById(R.id.seekbar);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
ToastMsg.ShowToast(SeekBarActivity.this,"SeekBar Progress : " + progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
ToastMsg.ShowToast(SeekBarActivity.this,"SeekBar Touch Started");
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
ToastMsg.ShowToast(SeekBarActivity.this,"SeekBar Touch Stopped");
}
});
}
}
0 comments:
Post a Comment