17

I have set up correctly the pref_general, values for it, and the code to run the intent:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        Intent intecao = new Intent(characterList.this, SettingsActivity.class);
        startActivity(intecao);
        return true;
    }

    return super.onOptionsItemSelected(item);
}

So if I hit settings in the options pop-up it will open correctly in my phone/7" tablet, but for bigger tablets such as 9" or more it will give me a blank screen pop-up without nothing written on it, such as this:

enter image description here

How can I fix this issue? What is the problem that makes this happen?

--- EDIT ---

Here is my pref_general:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory
        android:title="Made by Megafuji and Kintups"/>

    <ListPreference
        android:key="console1"
        android:title="Console"
        android:summary="Select your console"
        android:defaultValue="1"
        android:entries="@array/pref_example_list_titles"
        android:entryValues="@array/pref_example_list_values"
        android:negativeButtonText="@null"
        android:positiveButtonText="@null" />

    <ListPreference
        android:key="viewMode"
        android:title="View Mode"
        android:summary="Select your View Mode"
        android:defaultValue="1"
        android:entries="@array/pref_viewMode_list_titles"
        android:entryValues="@array/pref_viewMode_list_values"
        android:negativeButtonText="@null"
        android:positiveButtonText="@null" />

    <ListPreference
        android:key="charsize"
        android:title="Icons Size"
        android:summary="Select character screen size for text and icons."
        android:defaultValue="1"
        android:entries="@array/pref_character_size"
        android:entryValues="@array/pref_character_size_value"
        android:negativeButtonText="@null"
        android:positiveButtonText="@null" />

    <ListPreference
        android:key="tamanhoLetra"
        android:title="Font Size"
        android:summary="Select font size you want for move list."
        android:defaultValue="1"
        android:entries="@array/pref_font_size"
        android:entryValues="@array/pref_font_size_value"
        android:negativeButtonText="@null"
        android:positiveButtonText="@null" />

    <CheckBoxPreference
        android:key="screenDimming"
        android:title="Disable screen dimming in this app"
        android:summary="Disable screen locking/turning off."
        android:defaultValue="false"
        />

    <CheckBoxPreference
        android:key="frame"
        android:title="Show Frame Date"
        android:summary="Show Frame Data for All Moves "
        android:defaultValue="false"
        />

    <CheckBoxPreference
        android:key="damage"
        android:title="Show Damage"
        android:summary="Show Damage for All Moves "
        android:defaultValue="false" />

    <PreferenceCategory
        android:title="Contact us: mkxmoves@gmail.com"/>
</PreferenceScreen>
Cœur
  • 37,241
  • 25
  • 195
  • 267

3 Answers3

4

Found the answer!

All I needed to do following Android Developer Settings was that if I was developing for Android 3.0 (API level 11) and higher I needed to use Preference Fragments which is another class extending PreferenceFragment.

So the code would be using these parameters:

public static class SettingsFragment extends PreferenceFragment {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Load the preferences from an XML resource
        addPreferencesFromResource(R.xml.preferences);
    }
    ...
}

and the old SettingsActivity must now extend Activity instead of PreferenceActivity, as follows:

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

        // Display the fragment as the main content.
        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, new SettingsFragment())
                .commit();
    }
}
1
            public class SettingActivity extends PreferenceActivity
            {
                @Override
                protected void onCreate(Bundle savedInstanceState) 
                {
                    setTheme(android.R.style.Theme_Holo_Light_DarkActionBar);
                    requestWindowFeature(Window.FEATURE_ACTION_BAR);
                    super.onCreate(savedInstanceState);

                    FragmentManager mFragmentManager = getFragmentManager();
                    FragmentTransaction mFragmentTransaction = mFragmentManager
                            .beginTransaction();
                    PrefsFragment mPrefsFragment = new PrefsFragment();
                    mFragmentTransaction.replace(android.R.id.content, mPrefsFragment);
                    mFragmentTransaction.commit();
                }

               public static class PrefsFragment extends PreferenceFragment {

                @Override
                public void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);

                    // Load the preferences from an XML resource
                    addPreferencesFromResource(R.xml.preferences);
                    String userName;
                    String tmpemail;

                    findPreference("profile_setting_username").setTitle(userName);
                    findPreference("profile_setting_username").setSummary(strHtml);
                 }
             }
          }

This is how I have implemeted my Settings Activity and it works on all type of devices.
frogEye
  • 364
  • 3
  • 14
0

It's very likely you have a settings view in your XML for tablets that doesn't have your actual settings view elements.

You can read the Android docs for more information on supporting multiple views. Basically, the rules that are automatically set up are causing the XML view for tablets rather than phones to be used.

It should look something like this:

res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-large/my_layout.xml       // layout for large screen size
res/layout-xlarge/my_layout.xml      // layout for extra-large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra-large in landscape orientation

Either remove the XML file or update it to contain the settings elements you want.

Codeman
  • 12,157
  • 10
  • 53
  • 91