在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提供了关于应用环境全局信息的接口。它是一个抽象类,它的执行被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) |