Android专项练习题

-->1.  使用SimpleAdapter作为 ListView的适配器,行布局中支持哪些组件?

answer: 解决上述问题可以通过以下方式,

----->1.搜索SimpleAdapter的API Reference,

Android专项练习题_第1张图片


    -----> 2.在IDE中打开SimpleAdapter.java

/**
 * 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

------>3.通过以上资料,总结出

SimpleAdapter支持的View按照顺序分别为:

---->1.实现Checkable接口的View

---->2.TextView

---->3.ImageView


Reference


你可能感兴趣的:(Android专项练习题)