Reputation: 15738
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.record_fragment, container, false);
ListPreference listPreference = (ListPreference) findPreference("formats_listpref");
CharSequence currText = listPreference.getEntry();
String currValue = listPreference.getValue();
return v;
}
The method findPreference(String) is undefined for the type Browse_Fragment
I want to get the currently selected entryValues from ListPreference, I can get the value from Activity but when i use the same code in fragments, its not working findPreference(String) is undefined
i also tried getActivity().findPreference
but still it is showing as undefined. thanks in advance .
Upvotes: 0
Views: 195
Reputation: 753
I would check that your fragment extends PreferenceFragment i.e.
public class YourFragment extends PreferenceFragment {
...
}
Hope this helps.
Upvotes: 2