/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.widget;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.net.Uri;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* An easy adapter to map static data to views defined in an XML file. You can specify the data
* backing the list as an ArrayList of Maps. Each entry in the ArrayList corresponds to one row
* in the list. The Maps contain the data for each row. You also specify an XML file that
* defines the views used to display the row, and a mapping from keys in the Map to specific
* views.
*
* Binding data to views occurs in two phases. First, if a
* {@link android.widget.SimpleAdapter.ViewBinder} is available,
* {@link ViewBinder#setViewValue(android.view.View, Object, String)}
* is invoked. If the returned value is true, binding has occurred.
* If the returned value is false, the following views are then tried in order:
*
* - A view that implements Checkable (e.g. CheckBox). The expected bind value is a boolean.
*
- TextView. The expected bind value is a string and {@link #setViewText(TextView, String)}
* is invoked.
*
- ImageView. The expected bind value is a resource id or a string and
* {@link #setViewImage(ImageView, int)} or {@link #setViewImage(ImageView, String)} is invoked.
*
* If no appropriate binding can be found, an {@link IllegalStateException} is thrown.
*/
public class SimpleAdapter extends BaseAdapter implements Filterable {
private int[] mTo;
private String[] mFrom;
private ViewBinder mViewBinder;
private List extends Map> mData;
private int mResource;
private int mDropDownResource;
private LayoutInflater mInflater;
private SimpleFilter mFilter;
private ArrayList