Note that there are some explanatory texts on larger screens.

plurals
  1. POPreferenceFragment can't load from XML (ClassCastException)
    primarykey
    data
    text
    <p>I'm having some difficulties getting a PreferenceFragment to load using XML. It keeps throwing a <strong>ClassCastException</strong> "PreferenceFragmentClass cannot be cast to android.support.v4.app.Fragment". The code is intended to run on API14 and higher.</p> <p>Here's my code:</p> <pre><code>import android.os.Bundle; import android.preference.PreferenceFragment; public class SettingsFragment extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); } } </code></pre> <p>Here's the code where SettingsFragment is being used in:</p> <pre><code>import android.app.ActionBar; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.view.ViewPager; public class FragmentsSetup extends FragmentActivity { private ViewPager viewPager; private TabsAdapter tabsAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); viewPager = new ViewPager(this); viewPager.setId(R.id.pager); setContentView(viewPager); final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); tabsAdapter = new TabsAdapter(this, viewPager); tabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.forwarding_tab).toUpperCase()), ForwardingFragment.class, null); tabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.settings_tab).toUpperCase()), SettingsFragment.class, null); } } </code></pre> <p>Any tips would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload