PowenKo > Android >SeekBar

March 6, 2012   ·   0 Comments

Screen Shot 2012-03-07 at 1.19.21 AM

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
                                                }
});
}
}
shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Android7

Amazon

adsbygoogle

Recent Posts

Categories

Amazon