1/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.example.android.apis.view;
18
19import android.app.Activity;
20import android.os.Bundle;
21import android.widget.SeekBar;
22import android.widget.TextView;
23
24import com.example.android.apis.R;
25
26
27/**
28 * Demonstrates how to use a seek bar
29 */
30public class SeekBar1 extends Activity implements SeekBar.OnSeekBarChangeListener {
31
32    SeekBar mSeekBar;
33    TextView mProgressText;
34    TextView mTrackingText;
35
36    @Override
37    protected void onCreate(Bundle savedInstanceState) {
38        super.onCreate(savedInstanceState);
39
40        setContentView(R.layout.seekbar_1);
41
42        mSeekBar = (SeekBar)findViewById(R.id.seek);
43        mSeekBar.setOnSeekBarChangeListener(this);
44        mProgressText = (TextView)findViewById(R.id.progress);
45        mTrackingText = (TextView)findViewById(R.id.tracking);
46    }
47
48    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
49        mProgressText.setText(progress + " " +
50                getString(R.string.seekbar_from_touch) + "=" + fromTouch);
51    }
52
53    public void onStartTrackingTouch(SeekBar seekBar) {
54        mTrackingText.setText(getString(R.string.seekbar_tracking_on));
55    }
56
57    public void onStopTrackingTouch(SeekBar seekBar) {
58        mTrackingText.setText(getString(R.string.seekbar_tracking_off));
59    }
60}
61