ArrayAdapter(API分析)
来源:互联网 发布:淘宝视频制作 编辑:程序博客网 时间:2024/06/06 12:32
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
/>
这是xml文件中的demo,也是一个完整的布局文件,注意这里TextView是父控件,请看API中的注释:
The resource ID for a layout file containing a layout to use when instantiating views.意思是资源文件中需要包含一个layout布局才能实例化
The resource ID for a layout file containing a TexTview to use when instantiating views.意思是资源文件中需要包含一个TextView布局才能实例化
这两点要注意,要看好ArrayAdapter构造器参数,以及该怎么写布局文件。
public ArrayAdapter(Context context, int resource) {
init(context, resource, 0, new ArrayList<T>());
}
/**
* Constructor
*
* @param context The current context.
* @param resource The resource ID for a layout file containing a layout to use when
* instantiating views.(资源文件需要包含一个布局才能实例化)
* @param textViewResourceId The id of the TextView within the layout resource to be populated(寄存于)
*/
public ArrayAdapter(Context context, int resource, int textViewResourceId) {
init(context, resource, textViewResourceId, new ArrayList<T>());
}
/**
* Constructor
*
* @param context The current context.
* @param resource The resource ID for a layout file containing a TextView to use when
* instantiating views.
* @param objects The objects to represent in the ListView.
*/
public ArrayAdapter(Context context, int resource, T[] objects) {
init(context, resource, 0, Arrays.asList(objects));
}
/**
* Constructor
*
* @param context The current context.当前的上下文
* @param resource The resource ID for a layout file containing a layout to use when
* instantiating views.
* @param textViewResourceId The id of the TextView within the layout resource to be populated(居住于,寄存于)
* @param objects The objects to represent(表现,展示) in the ListView.
*/
public ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects) {
init(context, resource, textViewResourceId, Arrays.asList(objects));
}
/**
* Constructor
*
* @param context The current context.
* @param resource The resource ID for a layout file containing a TextView to use when
* instantiating views.
* @param objects The objects to represent in the ListView.
*/
public ArrayAdapter(Context context, int resource, List<T> objects) {
init(context, resource, 0, objects);
}
/**
* Constructor
*
* @param context The current context.
* @param resource The resource ID for a layout file containing a layout to use when
* instantiating views.
* @param textViewResourceId The id of the TextView within the layout resource to be populated
* @param objects The objects to represent in the ListView.
*/
public ArrayAdapter(Context context, int resource, int textViewResourceId, List<T> objects) {
init(context, resource, textViewResourceId, objects);
}
/**
* Adds the specified object at the end of the array.
*
* @param object The object to add at the end of the array.
*/
- ArrayAdapter(API分析)
- Android7.0中文文档(API)-- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- ArrayAdapter
- Arrayadapter
- ArrayAdapter
- ArrayAdapter
- poj 1182 食物链
- JavaScript 常见陷阱
- 10-hibernate组件关联关系映射
- java @override 报错处理
- 树莓派启动盘制作和备份
- ArrayAdapter(API分析)
- Coins (HDU 2844) —— 多重背包
- poj 1611
- VirtualBox下安装ubuntu出现单个文件超出了4G的提示
- import org.junit.Test;报错处理
- iOS App Archive 版本出错的问题 调试和解决方法
- 2014-7-15任务完成情况
- 截取指定长度的字符串(汉字不出现半个)
- 很好的技术博文推荐(持续更新)