blob: 037fb41c5726a456e0a41635cde8904cb3a8ca31 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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 android.preference;
18
19import android.content.Context;
20import android.graphics.drawable.Drawable;
21import android.preference.DialogPreference;
22import android.util.AttributeSet;
23import android.view.View;
24import android.widget.ImageView;
25import android.widget.SeekBar;
26
27/**
28 * @hide
29 */
30public class SeekBarPreference extends DialogPreference {
31 private static final String TAG = "SeekBarPreference";
Jim Miller4c8aafe2011-02-03 16:17:41 -080032
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033 private Drawable mMyIcon;
34
35 public SeekBarPreference(Context context, AttributeSet attrs) {
36 super(context, attrs);
37
38 setDialogLayoutResource(com.android.internal.R.layout.seekbar_dialog);
Jim Miller4c8aafe2011-02-03 16:17:41 -080039 createActionButtons();
40
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041 // Steal the XML dialogIcon attribute's value
42 mMyIcon = getDialogIcon();
43 setDialogIcon(null);
44 }
45
Jim Miller4c8aafe2011-02-03 16:17:41 -080046 // Allow subclasses to override the action buttons
47 public void createActionButtons() {
48 setPositiveButtonText(android.R.string.ok);
49 setNegativeButtonText(android.R.string.cancel);
50 }
51
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052 @Override
53 protected void onBindDialogView(View view) {
54 super.onBindDialogView(view);
Jim Miller4c8aafe2011-02-03 16:17:41 -080055
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056 final ImageView iconView = (ImageView) view.findViewById(android.R.id.icon);
57 if (mMyIcon != null) {
58 iconView.setImageDrawable(mMyIcon);
59 } else {
60 iconView.setVisibility(View.GONE);
61 }
62 }
63
64 protected static SeekBar getSeekBar(View dialogView) {
65 return (SeekBar) dialogView.findViewById(com.android.internal.R.id.seekbar);
66 }
67}