android - How to set custom layout for PreferenceActivity in Android 3.0?

前端 未结 3 1824
萌比男神i
萌比男神i 2021-02-07 09:15

I am developing app with minSdkVersion=\"11\", that is app for tablets and Android 4.0 and newer. I have scrutinized internet on this topic, but have not found much.

To

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-07 09:37

    I had the same issue than you.

    I tried a lot of stuff but here is my full code:

    https://github.com/iRail/BeTrains-for-Android/blob/master/src/tof/cv/mpp/MyPreferenceActivity.java

    The trick is to add the setContentView in the onBuildHeaders section, but NOT in the onCreate.

    I also made some tests in fragment and not perfectly sure why this is working, but I promise you: I have a custom layout on tablet header section!

    https://github.com/iRail/BeTrains-for-Android/blob/master/src/tof/cv/mpp/view/StockPreferenceFragment.java

提交回复
热议问题