- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将具有 listview 的布局设置为 popupwindow,然后设置 popupwindow.setFocusale(false);
,然后添加 "android:focusable="true""
属性到 listview,然后我点击弹出窗口中的listview,无法选择listview中的item,谁能告诉解决方案?提前致谢!
最佳答案
我遇到了同样的问题,在我的情况下需要 PopupWindow.setFocusble(false)
(并且在我的情况下使用 ListPopupWindow
不是解决方案,因为很多项目中的内容已经使用了基础 PopupWindow
的功能,包括扩展)。
如果有人处于相同情况,则有一种基于错误讨论的解决方法 here (#9 后)
主要思想是 ListView
的层次结构仍然接收触摸事件,因此我们可以手动触发 onItemClick()
。
但是,这种方法并不是 100% 与真正的 ListView
的触摸处理相同(就像在点击一行时没有选择发光一样)这对我来说目前做得很好。
如果有人对此问题有更精确的解决方案,请分享。
所以,这是完整的 Adapter
代码,它可以与 PopupWindow
中的 ListView
一起使用,即 setFocusable(false)
:
私有(private)类 CustomAdapter 扩展 ArrayAdapter {
private LayoutInflater mInflater;
private ListView mOwningListView;
public CustomAdapter(Context context, List<String> objects, ListView listView) {
super(context, android.R.layout.simple_list_item_1, objects);
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mOwningListView = listView;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.font_pick_row, null);
}
// this is the key point of workaround
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
/*
* as every row is still receiving their touches
* we can use this to manually trigger onItemClick
* since it doesn't firing in popupWindow.setFocusable(false)
*/
mOwningListView.getOnItemClickListener().onItemClick(mOwningListView, v, position, getItemId(position));
}
});
//... other stuff
return convertView;
}
关于Android:无法选中PopupWindow中的ListView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8753291/
我想在另一个 PopUpWindow 中打开一个 PopUpWindow。我的 MainActivity 中有一个 ImageButtons。当我单击它时,会出现一个 PopUpWindow。我在我的
在 Honeycomb 应用程序中,我在多个地方使用 PopupWindow 的自定义子类来显示各种 View 。这一切都很好,直到其中一个 View 碰巧尝试显示另一个 PopupWindow。 例
android PopupWindow 可以显示另一个 PopupWindow 吗?可以同时打开多少个 PopupWindow?只有一个? 第一个PopupWindow正常显示。但是在单击按钮时(在第
在我的应用程序中,我试图将包含 popupwindow 的 View 设置为不可见,并在一段时间后设置为可见。我的弹出窗口包含图像和文本,我希望弹出窗口的整个 View 及其内容根据某种逻辑显示和不显
当从单独的类调用 PopupWindow 方法时,我希望能够从 xml 文件定义 PopupWindow 中的布局。下面的代码根据需要工作,除了布局是从 java 文件而不是 xml 文件中提取的。在
谷歌开发团队的人能解释一下如何避免在 pre-ics 设备上发生这种崩溃吗?在我的例子中,ListView 项目上的 ImageButton 是 PopupWindow 的 anchor ,用于创建下
PopupWindow 膨胀得很好,直到它接近屏幕底部,它被切断了。有谁知道当它接近屏幕底部时如何让它向上膨胀? public SelectBucketMenu(Context context) {
这个问题已经有答案了: Android popup window dismissal (11 个回答) 已关闭 9 年前。 我创建了弹出窗口 public void myPopUp() {
要创建一个简单的工作 PopupWindow,我们需要执行以下操作: popup_example.xml: Java代码 LayoutInflater infl
有 PopupWindow 的 xml 文件: 如何以编程方式替换此 xml 中的图标和背景? 最佳答案 LinearLayout menuLayout= (LinearLayout) activit
要创建一个简单的工作 PopupWindow,我们需要执行以下操作: popup_example.xml: Java代码 LayoutInflater infl
我想在向其添加布局之前让 PopupWindow 至少显示一个空矩形。 这不起作用: public void configure() { LinearLayout linearLayout =
我在使用 PopupWindow android 默认小部件时遇到了问题。当我触摸按钮显示弹出窗口而不是按手机上的后退按钮时,在显示弹出窗口之前,我有强制关闭消息,接下来是错误: 10-14
如何将键事件从可聚焦的 PopupWindow 分派(dispatch)到基础 Activity。如果我设置窗口可聚焦,它会消耗所有事件。我希望能够拦截一个 key ,并处理事件。 这是我的困境:我的
我想通过点击窗口外部或按下后退按钮来关闭 PopupWindow。现在你可以点击屏幕上的任何地方,窗口会关闭,我不明白为什么。我还想给 PopupWindow 添加一个阴影。谢谢! 主要 Activi
在我的一个 Activity 中,有一个按钮,单击它会打开一个PopupWindow。我的 Intent 是,当 PopupWindow 打开并且用户单击屏幕上弹出区域以外的任何地方时,应该关闭 Po
目前,我在线性布局中有一个按钮,如下所示: 我还有一个 createPopup 扩展(它确实在单击按钮时执行)。 public void createPopup(View view) {
我有一个用于显示谷歌地图的弹出窗口,但一旦它打开我似乎无法关闭它,我试图设置后退按钮以关闭它但无法调用 onBackButtonClick当我在 fragment 中时覆盖。虽然似乎没有做任何事情
我想像 Google Keep 在创建提醒时那样在虚拟键盘上方显示一个 PopupWindow: 最佳答案 我相信,您正在寻找的是以下组合: popupWindow.setSoftInputMode(
我如何显示和隐藏同一个弹出窗口,而不是每次都创建一个对象。这就是我创建窗口的方式。我不想解雇();并出于性能原因每次重新创建窗口。 popupWindow = new PopupWindow(
我是一名优秀的程序员,十分优秀!