Android ExpandableListActivity 问题
我想自定义我的 ExpandableList。 我的问题是我需要一个关于单个活动的按钮和可扩展列表。 我能做到吗? 我已经看过所有示例,但所有示例都扩展了 ExpandableListActivity,而不是可以将所有小部件放在一个活动中的活动。 任何帮助,将不胜感激。
I want to customize my ExpandableList. My issue is that I need a button and expandable list on single activity. Can I achieve that? I have seen all the examples but all extends ExpandableListActivity not the Activity in which I can put all the widgets in one activity.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据文档,此任务应该不会太难。
您要做的第一件事是创建一个新的 xml 文件来保存您的自定义布局。 该文件应保存在您的 res/layout 文件夹中,并命名为“my_custom_expandable_list_view_layout.xml”,它应该如下所示:
该布局文件的导入部分是您包含一个“ExpandableListView”并为其指定 id 布局
您需要做的下一件事是通过调用 setContentView() 在您的活动 onCreate() 中。调用应该如下所示
此时您应该能够运行您进行编程并在屏幕底部看到一个大按钮,为了使用此按钮执行某些操作,您需要通过调用 findViewById() 在你的 Activity 中像这样
一旦你有了 myButton 对象,你就可以添加一个点击侦听器或任何你想要的东西做。 您几乎可以通过向布局文件添加新内容来添加您想要的任何其他内容。
According to the documentation this task should not be too hard.
the first thing that you will have to do is create a new xml file to hold your custom layout. The file should be saved in your res/layout folder and be named something like "my_custom_expandable_list_view_layout.xml", it should look something like this:
The import part of that layout file is that you include an "ExpandableListView" and give it the id of "android"list".
The next thing that you will need to do is let your activity know that you are using a custom layout by calling setContentView() in your activities onCreate(). The call should look something like this
At this point you should be able to run you program and see a large button at the bottom of the screen. In order to do something with this button you will need to access it via a call to findViewById() in your Activity like this
Once you have that myButton object you can add a click listener or whatever else you would like to do. You can pretty much add anything else you want by just adding new things to the layout file.