Code example for ListPreference

Methods: setEnabled, setValue

0
 
	private void checkGrade(String grade) {
		@SuppressWarnings("deprecation") 
		final ListPreference subgradesList = (ListPreference) findPreference("subgrades_list");
		if (grade.equals("EF") || grade.equals("Q1") || grade.equals("Q2")) {
			subgradesList.setEnabled(false);
			subgradesList.setValue(""); // Leeren
		} 
		else { 
			subgradesList.setEnabled(true);
		} 
	} 
 
	@Override 
	public void onBackPressed() { 
		Intent activity_intent = new Intent();
		activity_intent.setClass(getApplicationContext(), MainActivity.class);
		startActivity(activity_intent);
		this.finish();
		return; 
	}