ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list.
其中adapter 有ArrayAdapter<T>, BaseAdapter, CursorAdapter, HeaderViewListAdapter, ListAdapter, ResourceCursorAdapter, SimpleAdapter, SimpleCursorAdapter, SpinnerAdapter, WrapperListAdapter
这里我不对adapter进行描述,不管是哪种adapter都是为了将每条信息显示在listview上
每条显示的位置都是自己设计好的UI位置,下面我主要讲的是当你单击其中一个item时,如何获取其对应item的内容。
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3)
public abstract void onItemClick (AdapterView<?> parent, View view, int position, long id)
Parameters
parent The AdapterView where the click happened.
view The view within the AdapterView that was clicked (this will be a view provided by the adapter)
position The position of the view in the adapter.
id The row id of the item that was clicked.
TextView temp=(TextView)arg1.findViewById(R.id.wifi_SSID);
ssid=temp.getText().toString();
通过第二个参数,获取当前item对象内容,因为第二个对象是当前事件的对象,可查阅当然目标内容。
************************************************************************************************
飞扬小米(记)