<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:att="http://schemas.android.com/apk/res/com.att.control"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/textFieldslider"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a continuous Slider Control example."
android:textStyle="bold"
android:paddingBottom="10dp"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider"
att:max_value="100"
att:min_value="0"
att:divide_in="4"
att:current_value="5"/>
<TextView android:id="@+id/slide_bar_1_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_1"
android:text="Value: 10"
android:paddingBottom="10dp"/>
<TextView android:id="@+id/textFieldslider2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a segmented Slider Control example."
android:textStyle="bold"
android:layout_below="@id/slide_bar_1_text"
android:paddingBottom="10dp"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider2"
att:max_value="100"
att:min_value="-100"
att:divide_in="4"
att:current_value="-50"/>
<TextView android:id="@+id/slide_bar_2_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_2"
android:text="Value: 10"
android:paddingBottom="10dp"/>
<TextView android:id="@+id/textFieldslider3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a disabled Slider Control example."
android:textStyle="bold"
android:paddingBottom="10dp"
android:layout_below="@id/slide_bar_2_text"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider3"
att:max_value="20"
att:min_value="0"
att:divide_in="2"
att:current_value="5"/>
<TextView android:id="@+id/slide_bar_3_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_3"
android:text="Value: 10"
android:paddingBottom="10dp"/>
</RelativeLayout>
Full layout code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:att="http://schemas.android.com/apk/res/com.att.control"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/textFieldslider"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a continuous Slider Control example."
android:textStyle="bold"
android:paddingBottom="10dp"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider"
att:max_value="100"
att:min_value="0"
att:divide_in="4"
att:current_value="5"/>
<TextView android:id="@+id/slide_bar_1_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_1"
android:text="Value: 10"
android:paddingBottom="10dp"/>
<TextView android:id="@+id/textFieldslider2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a segmented Slider Control example."
android:textStyle="bold"
android:layout_below="@id/slide_bar_1_text"
android:paddingBottom="10dp"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider2"
att:max_value="100"
att:min_value="-100"
att:divide_in="4"
att:current_value="-50"/>
<TextView android:id="@+id/slide_bar_2_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_2"
android:text="Value: 10"
android:paddingBottom="10dp"/>
<TextView android:id="@+id/textFieldslider3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a disabled Slider Control example."
android:textStyle="bold"
android:paddingBottom="10dp"
android:layout_below="@id/slide_bar_2_text"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider3"
att:max_value="20"
att:min_value="0"
att:divide_in="2"
att:current_value="5"/>
<TextView android:id="@+id/slide_bar_3_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_3"
android:text="Value: 10"
android:paddingBottom="10dp"/>
</RelativeLayout>
Activity
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.att.widgets.lib.control.SliderControl;
public class SliderControlActivity extends Activity implements OnClickListener{
private SliderControl slider_1, slider_2, slider_3;
private TextView sliderText_1, sliderText_2, sliderText_3;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
slider_1 = (SliderControl)findViewById(R.id.slider_bar_1);
slider_2 = (SliderControl)findViewById(R.id.slider_bar_2);
slider_2.setStep(50.0f);
slider_3 = (SliderControl)findViewById(R.id.slider_bar_3);
sliderText_1 = (TextView)findViewById(R.id.slide_bar_1_text);
sliderText_2 = (TextView)findViewById(R.id.slide_bar_2_text);
sliderText_3 = (TextView)findViewById(R.id.slide_bar_3_text);
slider_2.setProgressFillColor(true);
slider_3.setEnabled(false);
slider_1.setOnClickListener(this);
slider_2.setOnClickListener(this);
slider_3.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == slider_1) {
sliderText_1.setText("Value: " + slider_1.getCurrent());
} else if (v == slider_2){
sliderText_2.setText("Value: " + slider_2.getCurrent());
} else if (v == slider_3){
sliderText_3.setText("Value: " + slider_3.getCurrent());
}
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:att="http://schemas.android.com/apk/res/com.att.control"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/textFieldslider"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a continuous Slider Control example."
android:textStyle="bold"
android:paddingBottom="10dp"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider"
att:max_value="100"
att:min_value="0"
att:divide_in="4"
att:current_value="5"/>
<TextView android:id="@+id/slide_bar_1_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_1"
android:text="Value: 10"
android:paddingBottom="10dp"/>
<TextView android:id="@+id/textFieldslider2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a segmented Slider Control example."
android:textStyle="bold"
android:layout_below="@id/slide_bar_1_text"
android:paddingBottom="10dp"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider2"
att:max_value="100"
att:min_value="-100"
att:divide_in="4"
att:current_value="-50"/>
<TextView android:id="@+id/slide_bar_2_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_2"
android:text="Value: 10"
android:paddingBottom="10dp"/>
<TextView android:id="@+id/textFieldslider3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a disabled Slider Control example."
android:textStyle="bold"
android:paddingBottom="10dp"
android:layout_below="@id/slide_bar_2_text"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider3"
att:max_value="20"
att:min_value="0"
att:divide_in="2"
att:current_value="5"/>
<TextView android:id="@+id/slide_bar_3_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_3"
android:text="Value: 10"
android:paddingBottom="10dp"/>
</RelativeLayout>
Full layout code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:att="http://schemas.android.com/apk/res/com.att.control"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/textFieldslider"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a continuous Slider Control example."
android:textStyle="bold"
android:paddingBottom="10dp"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider"
att:max_value="100"
att:min_value="0"
att:divide_in="4"
att:current_value="5"/>
<TextView android:id="@+id/slide_bar_1_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_1"
android:text="Value: 10"
android:paddingBottom="10dp"/>
<TextView android:id="@+id/textFieldslider2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a segmented Slider Control example."
android:textStyle="bold"
android:layout_below="@id/slide_bar_1_text"
android:paddingBottom="10dp"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider2"
att:max_value="100"
att:min_value="-100"
att:divide_in="4"
att:current_value="-50"/>
<TextView android:id="@+id/slide_bar_2_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_2"
android:text="Value: 10"
android:paddingBottom="10dp"/>
<TextView android:id="@+id/textFieldslider3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a disabled Slider Control example."
android:textStyle="bold"
android:paddingBottom="10dp"
android:layout_below="@id/slide_bar_2_text"/>
<com.att.widgets.lib.control.SliderControl
android:id="@+id/slider_bar_3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textFieldslider3"
att:max_value="20"
att:min_value="0"
att:divide_in="2"
att:current_value="5"/>
<TextView android:id="@+id/slide_bar_3_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/slider_bar_3"
android:text="Value: 10"
android:paddingBottom="10dp"/>
</RelativeLayout>
Activity
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.att.widgets.lib.control.SliderControl;
public class SliderControlActivity extends Activity implements OnClickListener{
private SliderControl slider_1, slider_2, slider_3;
private TextView sliderText_1, sliderText_2, sliderText_3;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
slider_1 = (SliderControl)findViewById(R.id.slider_bar_1);
slider_2 = (SliderControl)findViewById(R.id.slider_bar_2);
slider_2.setStep(50.0f);
slider_3 = (SliderControl)findViewById(R.id.slider_bar_3);
sliderText_1 = (TextView)findViewById(R.id.slide_bar_1_text);
sliderText_2 = (TextView)findViewById(R.id.slide_bar_2_text);
sliderText_3 = (TextView)findViewById(R.id.slide_bar_3_text);
slider_2.setProgressFillColor(true);
slider_3.setEnabled(false);
slider_1.setOnClickListener(this);
slider_2.setOnClickListener(this);
slider_3.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == slider_1) {
sliderText_1.setText("Value: " + slider_1.getCurrent());
} else if (v == slider_2){
sliderText_2.setText("Value: " + slider_2.getCurrent());
} else if (v == slider_3){
sliderText_3.setText("Value: " + slider_3.getCurrent());
}
}
}
No comments:
Post a Comment