在Android学习中,除了要把握住整个软件代码的整体结构外,我想对于新手来说,方法的参数的具体意义也是一个重要的问题,今天我对有关ListView中使用的方法进行总结“
(1)public<nobr><span class="sympad"><a href="http://developer.android.com/reference/android/widget/ArrayAdapter.html#ArrayAdapter(android.content.Context,%20int,%20T%5B%5D)">ArrayAdapter</a></span>(<a href="http://developer.android.com/reference/android/content/Context.html">Context</a>
context, int textViewResourceId, T[] objects)</nobr>
<nobr> ~~Context: 表示Android的上下文对象。</nobr>
<nobr> ~~t<span style="font-size:16px; white-space:nowrap">extViewResourceId:表示要使用的布局管理器。</span></nobr>
<nobr><span style="font-size:16px; white-space:nowrap"> <span style="white-space:pre"></span>~~<span style="font-size:16px; white-space:nowrap">T[] objects:要操作的数据内容。</span></span></nobr>
详解:
(1)什么是Context?
Context字面意思是上下文,位于framework
package的android.content.Context中,其实该类为LONG型,类似Win32中的Handle句柄。很多方法需要通过 Context才能识别调用者的实例:比如说Toast的第一个参数就是Context,一般在Activity中我们直接用this代替,代表调用者的实例为Activity,而到了一个button的onClick(View view)等方法时,我们用this时就会报错,所以我们可能使用ActivityName.this来解决,主要原因是因为实现Context的类主要有Android特有的几个模型,Activity以及Service。
Context提供了关于应用环境全局信息的接口。它是一个抽象类,它的执行被Android系统所提供。它允许获取以应用为特征的资源和类型。同时启动应用级的操作,如启动Activity,broadcasting和接收intents。
(2)android中自定的布局管理器有哪些,在哪里能够找到?
andorid本身提供了很多布局管理器:
相关的布局管理的具体说明参考文档:http://developer.android.com/reference/android/R.layout.html
监听事件中所使用的OnItemSelectedListener事件也是我们经常用到的,因此我们要覆盖方法
public abstract void onItemSelected
(AdapterView<?> parent,
View view, int position, long id)
Callback method to be invoked when an item in this view has been selected. This callback is invoked only when the newly selected position is different from the previously selected position or if there was no selected item.
Impelmenters can call getItemAtPosition(position) if they need to access the data associated with the selected item.
(鉴于此项目已被选定时,被调用的回调方法。只有当新选定的位置从先前选定的位置是不同的,如果没有选定的项目,这个回调函数被调用。
impelmenters可致电getItemAtPosition(位置),如果他们需要访问与所选项目相关的数据。)
Parameters
parent
The AdapterView where the selection happened(选择发生的AdapterView)
|
view
The view within the AdapterView that was clicked(View被点击AdapterView) |
position
The position of the view in the adapter(适配器中点击viewd的位置) |
id
The row id of the item that is selected (选定行目的ID) |
分享到:
相关推荐
android之listview学习笔记附源码,多种adapter获取数据,获取用户焦点
android关于listview之列表分组,像Q上一样显示列表项
Android利用listview浏览新闻
android多选ListView示例
Android开发中listview属性的介绍
Android使用ListView实现时间轴
利用android studio实现listview嵌套listview,技术含量不是特别高,希望能帮助大家,这里就意思一下,给1分算啦
Android 单击listview弹出popupwindow弹出框,里面还附带listview右滑删除按钮。博客网址:http://blog.csdn.net/qq_16064871
通过一个例子实现ListView列表视图并且点击不同的项进入不同的界面,需要的可以看看
android 使用ListView来实现表格
Android ListView边框圆角美化,可以用来仿iphone的个别界面。相当有用。美观。
Android ListView每个Item上面的有TextView和Button,为ListView每个Item上面的按钮添加事件,并获取TextView文本信息。
android 一些listview不同的例子
Android 实现ListView滚动到底部自动加载数据
Android ListView卡片效果,源码下载。
ListView与BaseAdapter的配套使用 理解android 中adapter适配的作用 以及ListView的优化方式
该资源是一个完整的Android应用,主要是ListView列表视图的实现,并实现了每个列表项的事件。
android用ListView实现表格样式
Android中ListView的简单使用,BaseAdapter的简单使用,ListView添加表头headView表尾bootView
Android实现ListView的增删改查Demo