问题标签 [onitemclick]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
3348 浏览

android - 当我单击 ListView 的一项时,我想关闭 AlertDialog

我是安卓应用开发者。我想显示 AlertDialog 包括 Listview。

当我单击 ListView 的一项时,我想关闭 AlertDialog。但是,(1)代码不起作用。

我能怎么做?

请告诉我一些建议。预谢谢!

0 投票
4 回答
1759 浏览

android - 未调用 ListView 自定义 OnItemClickListener

好的,在过去的几个小时里,我一直在努力弄清楚为什么我的自定义列表视图适配器无法与 OnItemClickListener 一起正常工作。我有一个 TextView,我使用 DrawableLeft 属性在 ListView 内的 textview 左侧绘制图像。现在在我的文本视图中,我确实将 android:focusable 和 android:focusableInTouchMode 以及 android:clickable all 设置为 false,并且在我的列表视图的根目录中,我将 android:descendantFocusability 设置为 blocksDescendants,因为这些是遇到这个确切问题的常见问题. 现在这是我要使用的布局文件:

这是我的 TextView 布局:

我在从 BaseAdapter 派生的类的 getView 函数中以编程方式设置了 DrawableLeft Image。至于我在其中实现 OnItemClickListener 函数的活动有点像这样:

这是我的自定义适配器:

}

MenuItem 类只是我需要的字段的设置器和获取器......

我无法启动它,我不明白如果需要更多代码,为什么会感谢任何帮助,只是让我知道只是不想发布所有内容。BaseAdapter 的子类非常简单,它只是使用 setCompoundDrawablesWithIntrinsicBounds 设置 TextView 和 DrawableLeft 字段的文本。如果有人可以提供帮助,将不胜感激。

0 投票
1 回答
2125 浏览

android - how to Get data from SQLite database to intent through “onItemClick” on item in ListView Android

I apologize in advance, I am from Indonesia, so my English may not be good .. I just translate me through google translate

I'm making a android app associated with sqlite. the problem I have, I want to display data from the database according to the selected listview. application is an application that I made a tour guide.

while running the application, will be performing some of the category of existing attractions. if one of the selected categories, such as category: Nature, it will show a list of names that exist in nature in the form of a database listview.

I managed to get it up here.

after that, if I choose one of the name of nature, such as: Losari, it will show a description of Losari according to the database.

I am confused how to display as I described above .. please help me

this file alam.java for displaying listview whose data retrieved from the database

This file deskAlam.java will display a description of the selected option in listview

please fix it if something goes wrong or less of the source code I mentioned above

0 投票
0 回答
488 浏览

android - ListItem 在 Android 中不可触摸/可点击

我有我的扩展 ListActivity 的 MainActivity 类,我将适配器设置为通过方法中的自定义适配器列出onResume()

处理列表项点击,我用这个

但是当通过鼠标单击/触摸项目时它不起作用,它仅在我将它与选择并实现的项目一起使用时才起作用onItemSelectedListener

这仅适用于模拟器上的箭头键,但在真实设备上,(通常)它们没有箭头/导航键,如何定义列表项的单击?

编辑:row_item.xml

0 投票
2 回答
5623 浏览

c# - 获取 Clicked ListView 项目属性

我有一个带有 ListView 的 Windows 8 应用程序:

有一些 Event 对象(一个单独的类,具有 EventType、Description、Time 等字符串属性)是 ListView 的来源:

我试图访问点击项目的信息,但它似乎没有设置:

如何获取单击项目的事件属性?

0 投票
2 回答
847 浏览

android - Android-onItemClick 将正确的值传递给意图

如何从我的 GridView 获取正确的值以传递给我的意图。看来我做错了。所以这就是我所做的:

在我的 MainActivity 中:

我的 CategoryRowItem 类:这有 getter 和 setter

那么,我怎样才能获得正确的值,如 catID 或单击的项目的 catName>

0 投票
2 回答
608 浏览

android - OnItemClick 不响应点击

搜索了listview OnClick not working pages,没有解决。

我的活动通过调用 扩展ArrayAdapter类的自定义适配器MyArrayAddapter来填充列表视图。

问题:onItemClick() 或 setOnItemClick() 没有响应。

当我单击任何项​​目时,不会发生任何操作,甚至不会执行日志语句。

<<>>

代码片段:

在扩展 Activity 的类实现 OnItemClickListener 下,我在 OnCreate() 方法中初始化并调用以下函数:

连吐司都没有出现:(

注意:当我单击列表视图的一个项目时,我会得到完全相同的消息,只是时间戳不同。我收到 7-8 条这样的新消息。点击前的 LogCat:

点击后:

活动布局:

行项目的布局:

它第一次完美填充,但我希望当我单击时我应该能够通过更改参数并再次调用 setAdapter() 方法来重新填充它。

解决这个问题肯定会帮助许多其他人,因为我看到许多人有未解决的疑问。

有问题的类的java文件:

LOGCAT 更新:在 3 个按钮上使用 focusable:false 属性后。

0 投票
2 回答
304 浏览

android - Android:在搜索搜索建议上,每次点击它打开新的活动,我们可以打开相同的活动不同的数据

我已经实现了自定义搜索建议,在建议点击我开始详细活动并显示数据很好时,问题是每当我点击建议为每个建议打开新活动时。例如:我有建议苹果球猫

当我点击 Apple 打开一个带有 Apple 数据的详细活动时,我现在再次点击了搜索点击了 Ball 并打开了带有 Ball 数据的详细活动

当我单击后退按钮时,它会导航回 Apple 详细信息活动,那么如何避免为每个建议打开新的详细信息活动。

0 投票
5 回答
9948 浏览

android - 实现 OnItemClickListener,但 onItemClick 不起作用

在 MainActivity 中有 onItemClick,Activity 实现了 OnItemClickListener。一切都很简单,这个监听器的结果是当用户触摸 ListView 的一个项目时,在屏幕上打印一条 Toas 消息。但是onItemClick函数不起作用,为什么?[logCat 没有错误] 在此先感谢。

这是我的主要活动代码:

我的activity_main.xml:

我的 row.xml 用于适配器的每个项目:

0 投票
3 回答
726 浏览

android - 试图从 ListView 获取字符串

我目前的问题是我有一个 ListView 我用来显示我的联系人现在我想设置 onItemClick 来获取联系人的名称并将其设置为一个名为 p2 的 TextView 我目前拥有的代码是:

所以基本上我不确定我需要在 onItemClick 中做什么,任何帮助表示赞赏!