我试着去追查点击我的图像视图被点击时,但我似乎无法拿起触摸,任何想法?
imgView.setOnClickListener(新View.OnClickListener(){
公共无效的onClick(视图v){
Log.v(TAG,点击);
}
});
解决方案
图像通常是不可点击的,所以我建议你把定义
机器人:可点击=真正的
在你的layout.xml到ImageView的。
如果这没有帮助,请编辑+更新您的问题,告诉我们您的布局,其中定义图像看看它的一部分。
编辑: 试了一下,你的code和我一起工作过 - 即使有大写ID名称。 能否请你要仔细看看你的LogCat中? 矿山有时候并没有真正更新,只要我不要再选设备。
要做到这一点在Eclipse中,进入查看设备(或通过窗口首先表现出来),并单击一次设备/虚拟设备上。
如果你还没有找到在LogCat中,查看你的日志条目,尝试创建一个过滤器(通过绿色加,并给予它你定义字符串变量
为通过日志标签)。
看一看 Android开发>使用DDMS 在节使用LogCat中
Im trying to trace a click when my image view is clicked, but I cannot seem to pick up the touch, any ideas?
imgView.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
Log.v(TAG, " click");
}
});
解决方案
Images normally aren't clickable, therefore I would suggest that you put the definition
android:clickable="true"
in your layout.xml to the imageView.
If this is not helping, please edit+update your question and show us the part of your layout, where you define the image to have a look at it.
EDIT: Tried it, and your code worked with me too - even with the upper case id name. Can you please have a close look at your LogCat? Mine sometimes doesn't really update, as long as I don't choose the device again.
To do so in Eclipse, go to the View "Devices" (or show it first via "Window") and click once on your device / virtual device.
If you still don't find your log entry in the LogCat-View, try to create a filter (via the green plus and giving it the String you defined with TAG
as "by Log Tag").
Have a look at android developers > Using DDMS at the section "Using LogCat"