Home » » Android Simple SeekBar Example

Android Simple SeekBar Example

Written By MR HARI on Senin, 02 Mei 2011 | 05.49


SIMPLE SEEKBAR

SOURCE CODE [main.xml] is

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<TextView  android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />

<SeekBar android:id="@+id/seekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:max="100"
android:minWidth="250px"  />

<TextView android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout


SOURCE CODE [SeekBarExample.java] is

package com.SeekBarExample;

import android.app.Activity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class SeekBarExample extends Activity
{
SeekBar seekbar;
TextView value;

public void onCreate(Bundle savedInstanceState)
{

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
       
value = (TextView) findViewById(R.id.textview);
 seekbar = (SeekBar) findViewById(R.id.seekbar);
       
                                seekbar.setOnSeekBarChangeListener( new OnSeekBarChangeListener()
{
public void onProgressChanged(SeekBar seekBar, int progress,
                                                                boolean fromUser)
{
                                                                // TODO Auto-generated method stub
                                                                value.setText("SeekBar value is "+progress);
                                                }

                                                public void onStartTrackingTouch(SeekBar seekBar)
{
                                                                // TODO Auto-generated method stub
                                                }

                                                public void onStopTrackingTouch(SeekBar seekBar)
{
                                                                // TODO Auto-generated method stub
                                                }
});
}
}


The OUTPUT will be

 https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk1qGnaDYrXDez_qLH1YbUsb6gKlYRb_zolbT-LzGccJG917Df123xnFevzLQ0k1RGH-f_0EGAcQBVK5grKSt8TFNj2Yydu8OJkeV4It3a35IKbqNRQHIa9Wu89dQpO5AtuaQHx-ppH08/

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT9tGBSCWTT82GYqL5E5SEeD9Y6qKTGsPB_qf0WMav3EPrCYkU7efPlO-d4W2dqYJgtL27nsy_bnaHanbARmS7zkBsTWDJKts5k4PdDs6oBtVx1FzsVzMWhdpUKl3XArM6l7YaFGohJxI/
Share this article :

0 komentar:

Posting Komentar

 
Support : Your Link | Your Link | Your Link
Copyright © 2013. Android Center - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger