Home | History | Annotate | Download | only in widget
      1 /*
      2  * Copyright (C) 2006 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 android.widget;
     18 
     19 import android.content.Context;
     20 import android.graphics.drawable.Drawable;
     21 import android.net.Uri;
     22 import android.util.AttributeSet;
     23 import android.view.accessibility.AccessibilityEvent;
     24 import android.view.accessibility.AccessibilityNodeInfo;
     25 
     26 
     27 public class ImageSwitcher extends ViewSwitcher
     28 {
     29     public ImageSwitcher(Context context)
     30     {
     31         super(context);
     32     }
     33 
     34     public ImageSwitcher(Context context, AttributeSet attrs) {
     35         super(context, attrs);
     36     }
     37 
     38     public void setImageResource(int resid)
     39     {
     40         ImageView image = (ImageView)this.getNextView();
     41         image.setImageResource(resid);
     42         showNext();
     43     }
     44 
     45     public void setImageURI(Uri uri)
     46     {
     47         ImageView image = (ImageView)this.getNextView();
     48         image.setImageURI(uri);
     49         showNext();
     50     }
     51 
     52     public void setImageDrawable(Drawable drawable)
     53     {
     54         ImageView image = (ImageView)this.getNextView();
     55         image.setImageDrawable(drawable);
     56         showNext();
     57     }
     58 
     59     @Override
     60     public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
     61         super.onInitializeAccessibilityEvent(event);
     62         event.setClassName(ImageSwitcher.class.getName());
     63     }
     64 
     65     @Override
     66     public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
     67         super.onInitializeAccessibilityNodeInfo(info);
     68         info.setClassName(ImageSwitcher.class.getName());
     69     }
     70 }
     71