• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.example.android.apis.view;
18 
19 import android.app.Activity;
20 import android.os.Bundle;
21 import android.widget.SeekBar;
22 import android.widget.TextView;
23 
24 import com.example.android.apis.R;
25 
26 
27 /**
28  * Demonstrates how to use a seek bar
29  */
30 public class SeekBar1 extends Activity implements SeekBar.OnSeekBarChangeListener {
31 
32     SeekBar mSeekBar;
33     TextView mProgressText;
34     TextView mTrackingText;
35 
36     @Override
onCreate(Bundle savedInstanceState)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 
onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch)48     public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
49         mProgressText.setText(progress + " " +
50                 getString(R.string.seekbar_from_touch) + "=" + fromTouch);
51     }
52 
onStartTrackingTouch(SeekBar seekBar)53     public void onStartTrackingTouch(SeekBar seekBar) {
54         mTrackingText.setText(getString(R.string.seekbar_tracking_on));
55     }
56 
onStopTrackingTouch(SeekBar seekBar)57     public void onStopTrackingTouch(SeekBar seekBar) {
58         mTrackingText.setText(getString(R.string.seekbar_tracking_off));
59     }
60 }
61