Is there any way to add a button to the bottom of preferences screen and make them work correct when scrolling?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
I know this is a bit late, but I just found a solution i like better than Max's praised solution.
You can simply add a footer (or if you like the button to be on top, a header) to the PreferenceActivity's ListView like so:
I hope this helps someone.
The following is a simple solution to add a clickable button to your preference screen. This is made easy because the preferences already reserve the space in the android:widgetLayout and the button can pass clicks with android:onClick.
First create a button.xml with the content
Now in your preferences.xml, add the preference
Your PreferenceActivity now only has to contain a onButtonClick member
You just need to use PreferenceFragment inside general Activity and add the button into activity layout.
SettingActivity.java
activity_setting
This example below will render a button at the bottom of the page (in case anybody is still interested).
In case of a LinearLayout you could also apply weights; this is needed because the Listview is set to *fill_parent*. I usually do this by adding *android:layout_weight* 's:
The explanation below isn't propbably 100% but it will help you understand...
You could also say, because the Button has no weight; the button is rendered at 0dp height.
Now with the layout_weigths added it will lett the button render inview
It is also possible to add Action buttons to the action bar for an android standard approach.
This would be what the code looks like in the activity at the ronny's example. My intent was to put an menu in the bottom side of the screen.