• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Preference Fragment Issue

Muqali

Lurker
Jun 20, 2014
6
0
Hello all, going through Bucky's tutorial and it is a bit outdated, I've been able to figure out most issues but am running into a brick wall with the idea of the preference fragment. My program is crashing every time I click on preferences. Here is my code

Prefs.java:
Code:
package com.example.testapp;

public class Prefs extends PreferenceFragment {

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

        addPreferencesFromResource(R.xml.prefs);
    }
}

prefs.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" >

    <EditTextPreference
        android:key="name"
        android:summary="Enter Your Name"
        android:title="EditText" />

</PreferenceScreen>

Inside my Menu.java I have:
Code:
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {


	        Intent p = new Intent("com.example.testapp.PREFS");
		startActivity(p);


		return false;
	}

Any ideas?

Thanks!
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones