将自定义 ListView 适配器与默认 Android 主题结合使用
我正在 Honeycomb 上使用 ListView 开发一个应用程序。当使用普通的 ArrayAdapter 来提供 ListView 内容时,我可以向它传递一个内置布局,例如 Android.R.layout.simple_selectable_list_item。当选择与整体蜂窝感觉一致的项目时,这会创建一个具有漂亮淡入淡出动画的可点击项目。
但是,如果我决定使用自己的自定义布局(或创建自定义适配器),则在关注或选择 ListView 中的项目时不再有任何动画。我可以构建自己的动画,但在为 Honeycomb 开发时,为了简单性和一致性,我更愿意使用默认的 Holo 主题。
我不知道如何做到这一点,并且无法找到其他人与我的斗争(也许我正在搜索错误的术语,或者错过了一些明显的东西!)。有人有什么建议吗?我认为这涉及到在布局的 XML 文件中识别某种样式或主题,但我还没有弄清楚将其放在哪里或内容可能是什么。
谢谢!
I'm developing an app on Honeycomb with a ListView. When using a normal ArrayAdapter to feed the ListView content, I can pass it a built-in layout such as Android.R.layout.simple_selectable_list_item. This creates a clickable item with a nice fading animation when selecting an item that is consistent with the overall Honeycomb feel.
However, if I decide to use my own custom layout (or to create a custom adapter), I no longer have any animation when focusing on or selecting an item in the ListView. I could construct my own animation, but I would prefer to use the default Holo theme when developing for Honeycomb for simplicity and consistency.
I'm at a loss for how to do this and haven't been able to find anyone else with my struggle (perhaps I'm searching the wrong terms, or am missing something obvious!). Does anyone have any suggestions? I figure it involves identifying some sort of style or theme in the XML file for the layout, but I haven't figured out where to put that or what the contents might be.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
明白了:我必须删除 ListView 中对 android:listSelector 和 android:background 的所有引用。然后我添加
到 ListView 行布局的顶级视图中。
Got it: I had to remove all references to android:listSelector and android:background for my ListView. Then I added
to my top-level view for the ListView row layout.