1

i am new to android and i am working on preference headers. i have few queries on preferences. here are they

  1. Can preference headers and preference switch can be on same page. eg, first two options will be wifi and bluetooth as preference headers. On clicking on any of them should lead to new preference screen. Third option should be switch preference which should be worked only for ON and OFF of switch. touch click on the switch reference shouldn't launch new preference screen. I tried to add a switch preference in class along with onbuildheaders, It is not working.

  2. should preference header always linked with a fragment to open a new preference screen?? can a preference header created without fragment?

  3. does preference header will have touch sensitivity by default??

  4. can we disable new preference screen which will be opened after tapping on the preference header. eg. bluetooth is preference header which has ON/OFF switch. if switch is ON, it will enable bluetooth and if it is OFF, bluetooth should be disabled. Tapping on bluetooth header should nt open preference.

Here is XML file ` headers.xml

<preference-headers
        xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Header1 -->
    <header
        android:id="@+id/Header1"
        android:fragment="com.android.Headers.header1"
        android:title="@string/Header1"


    <!-- Header2 -->
    <header
        android:id="@+id/Header2"
        android:fragment="com.android.Headers.header2"
        android:title="@string/Header2"

   <!-- Header3-->
    <header
        android:id="@+id/Header3"
        android:title="@string/Header3" /> 
</preference-headers>`

Here am loading Headers

public void onBuildHeaders(List headers) { loadHeadersFromResource(R.xml.headers, headers);

Abhishek
  • 71
  • 8
  • One thing let me tell you, don't use `PreferenceActivity` , `PreferenceFragment` because, all are depricated. – Nigam Patro Dec 04 '15 at 05:32
  • @NigamPatro Yes. you are right . But i have to use preference activity and preferenceFragment. Pls share inputs if you have idea on them. It will be really helpful – Abhishek Dec 04 '15 at 06:15
  • But you can use SharedPreference instead. in place of PreferenceActivity and PreferenceFragment. – Nigam Patro Dec 04 '15 at 06:17
  • actually what i need is preference header with Switch button and not linked to Fragment. When i am not linking to fragment, It is just becoming sub part of other preference header and switch is vanished. – Abhishek Dec 04 '15 at 06:22
  • Can you just post your code. – Nigam Patro Dec 04 '15 at 06:24

0 Answers0