![When When](https://c1.lmlphp.com/image/static/default_avatar.gif)
本文介绍了安卓:onListItemClick的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
previous一次我问一个问题,我在这里学到了很多东西,所以我想这是值得一试再试一次吧。
我现在用的是懒惰的名单由费多尔从这个链接:How我做的ListView图像的延迟加载?
它的工作就像一个魅力。但费多尔正在他的主要类扩展活动
,而不是 ListActivity
的。正因为如此,我不再能够使用listItemClick监听器。 Eclipse的声明身边 onListItemClick一些错误()
。它的工作原理当我打开
@覆盖
保护无效onListItemClick(ListView的L,视图V,INT位置,长的id){
super.onListItemClick(L,V,位置ID);
这里//意图发射
}
到
保护无效onListItemClick(ListView的L,视图V,INT位置,长的id){
这里//意图发射
}
但意图发射器不工作。无论是做了Toast通知。
当我打开活动
在 ListActivity
,Eclipse不错开,但我的模拟器给了我强制关闭。
如何获得
- 为
onListItemClick()
点击活动(preferable) - 或者我变换code到
ListActivity
没有强制关闭?
感谢很多提前。
解决方案 一个listItemClickListener连接到的ListView
。当您更改
ListActivity
到
活动
,你的该类已不再具有与其关联的视图,因此一个
活动
类有不知道该怎么做一个onListItemClickListener。
您只需要连接一个监听到你的的ListView
:
listview.setOnItemClickListener(新onItemClickListener(){
@覆盖
保护无效onListItemClick(){
//做的东西
}
});
Previous time I asked a question here I learned a lot so I guess it's worth a shot to try it again.
I am using the lazy list by Fedor from this link:How do I do a lazy load of images in ListView?
It's working like a charm. BUT, Fedor is making his main class extend Activity
instead of ListActivity
. Because of this, I am no longer able to use a listItemClick listener. Eclipse declares some errors around onListItemClick()
. It works when I turn
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// Intent launcher here
}
into
protected void onListItemClick(ListView l, View v, int position, long id) {
// Intent launcher here
}
But the intent launcher doesn't work. Neither does a toast notification.
When I turn the Activity
in a ListActivity
, Eclipse doesn't stagger, but my emulator gives me a force close.
How do I get
- Either
onListItemClick()
click in the activity (preferable) - Or do I transform the code into a
ListActivity
without force close?
Thanks a lot in advance.
解决方案
A listItemClickListener is attached to a ListView
. When you changed ListActivity
to Activity
, your class no longer has a view associated with it and thus an Activity
class has no idea what to do with an onListItemClickListener.
You just have to attached a listener to your ListView
:
listview.setOnItemClickListener(new onItemClickListener(){
@Override
protected void onListItemClick(){
//Do stuff
}
});
这篇关于安卓:onListItemClick的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
08-04 04:02