Android专项练习题

来源:互联网 发布:在职研究生网络教育 编辑:程序博客网 时间:2024/06/06 02:01

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

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

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



    -----> 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: * <ul> * <li> A view that implements Checkable (e.g. CheckBox).  The expected bind value is a boolean. * <li> TextView.  The expected bind value is a string and {@link #setViewText(TextView, String)}  * is invoked. * <li> ImageView. The expected bind value is a resource id or a string and  * {@link #setViewImage(ImageView, int)} or {@link #setViewImage(ImageView, String)} is invoked.  * </ul> * 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


0 0