解决方案 »
- 安卓 怎样实现一个文件选择,最好能调用本机的文件选择器?
- android 如何让自定义dialog的宽度充满整个屏幕?
- Intent.ACTION_SEND时启动指定的Activity
- 百度地图Apiandroid公交车搜索transitOverlay类 提示找不到:icon_nav_start_h.png
- 谁能提供一下完整版的可编译的Android2.2系统几个自带程序的源码吗?
- 有人知道FaceDetector类是通过什么原理实现的吗?用到opencv了吗?
- 在编写Intent 时出现undefined错误如何解决啊。
- 模拟乒乓球的状态
- Checkable里面的setChecked方法
- 服务器传给很多个用户的用户信息 客服端这边要怎么去接收啊
- 如何全局捕获key
- 他们的结算率到底咋样啊!
Toast.makeText(getApplicationContext(), Chapter8.items[position], Toast.LENGTH_SHORT).show();
}
public void onListItemClick (ListView parent, View view, int position, long id){
//int position 是点击选中的列表的index
}
* when click one,show the title
* @param l
* @param v
* @param postion
* @param id
*/
@Override
protected void onListItemClick (ListView l, View v, int position, long id) {
if(null == v){
Log.e(_TAG,"onListItemClick : paramter : v is null");
}else{
//get the _TITLE of the clicked item
HashMap<String,Object> item = (HashMap<String,Object>)l.getItemAtPosition(position);
String title = (String)item.get(_TITLE);
Toast.makeText(getApplicationContext(), "Kick it !" + title, Toast.LENGTH_SHORT).show();
}
}
null, DiaryColumns.DEFAULT_SORT_ORDER);
//构建适配器
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.diary_row, cursor, new String[] { DiaryColumns.TITLE,
DiaryColumns.CREATED }, new int[] { R.id.text1,
R.id.created });
setListAdapter(adapter);那么,在重写方法onListItemClick(...)时,便需要将获取到的ListView中的项类型定义为Cursor类型
如下Cursor c = (Cursor)l.getItemAtPosition(position);
String s = c.getString(1);
Toast.makeText(ActivityMain.this, "" + s, Toast.LENGTH_LONG).show();总的来说,如若需要重写ListView中的onListItemClick(即响应该项被单击),获取该具体项时,其类型由构造ListView的适配器决定。