2015-09-05 8 views
5

मैंने एंड्रॉइड डेवलपर्स से गाइड "सेटिंग्स" का पालन किया है। लेकिन जब मैं अपनी सेटिंग्स एक्टिविटी लॉन्च करता हूं तो मुझे लगता है कि सफेद स्क्रीन है। मैं क्या गलत कर रहा हूं?एंड्रॉइड स्टूडियो में सेटिंग गतिविधि कैसे सेट करें?

यहाँ यहाँ मेरी SettingActivity.java

public class SettingsActivity extends Activity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     getFragmentManager().beginTransaction() 
       .replace(android.R.id.content, new SettingsFragment()) 
       .commit(); 
    } 
} 

है SettingFragment है

public class SettingsFragment extends PreferenceFragment { 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     addPreferencesFromResource(R.xml.preferences); 
    } 
} 

यहाँ वरीयताओं फ़ाइल है

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> 
    <EditTextPreference android:title="Your Name" 
     android:key="username" 
     android:summary="Please provide your username"></EditTextPreference> 
    <CheckBoxPreference android:title="Application Updates" 
     android:defaultValue="false" 
     android:summary="This option if selected will allow the application to check for latest versions." 
     android:key="applicationUpdates" /> 
    <ListPreference  android:title="Download Details" 
     android:summary="Select the kind of data that you would like to download" 
     android:key="downloadType" 
     android:defaultValue="1" 
     android:entries="@array/listArray" 
     android:entryValues="@array/listValues" /> 
</PreferenceScreen> 

और इस तरह मैं SettingsActivity करने के लिए स्विच है

Intent intent = new Intent(MainActivity.this, SettingsActivity.class); 
          startActivity(intent); 

क्या सफेद स्क्रीन को खुश किया जाना चाहिए? मैं सेटिंग्स के साथ एक डिफ़ॉल्ट स्क्रीन की उम्मीद कर रहा हूं

उत्तर

2

मुझे समाधान मिला।

स्क्रीन खाली नहीं थी, मेरी थीम ने सफेद पृष्ठभूमि पर सभी पाठ को सफेद बना दिया।

तो मैं बस सेटिंग्स गतिविधि के लिए एक कस्टम थीम जोड़ा गया है और एंड्रॉयड प्रकट करने के लिए इस कहा:

 android:theme="@style/SettingsTheme" 
+0

अपनी शैली –

+0

"है" जहां SettingsTheme पोस्ट? –

+0

आप जो कुछ भी चाहते हैं उसे सेट कर सकते हैं, इंटेलिजे अमीया, मेरा <शैली का नाम = "सेटिंग्सथीम" पैरेंट = "थीम.एप कॉम्पेट.लाइट"> –

संबंधित मुद्दे