1/* 2 * Copyright (C) 2012 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.support.v4.widget; 18 19import android.content.Context; 20import android.view.View; 21import android.widget.SearchView; 22 23/** 24 * Implementation of SearchView compatibility that can call ICS APIs. 25 */ 26class SearchViewCompatIcs { 27 28 public static class MySearchView extends SearchView { 29 public MySearchView(Context context) { 30 super(context); 31 } 32 33 // The normal SearchView doesn't clear its search text when 34 // collapsed, so we will do this for it. 35 @Override 36 public void onActionViewCollapsed() { 37 setQuery("", false); 38 super.onActionViewCollapsed(); 39 } 40 } 41 42 public static View newSearchView(Context context) { 43 return new MySearchView(context); 44 } 45 46 public static void setImeOptions(View searchView, int imeOptions) { 47 ((SearchView) searchView).setImeOptions(imeOptions); 48 } 49 50 public static void setInputType(View searchView, int inputType) { 51 ((SearchView) searchView).setInputType(inputType); 52 } 53} 54