Norway


Hi, I am trying to create a for my , however I am having difficulty with at least one line of code R; not sure whether android support this code anymore so your suggestions could be helpful. Thanks!

Code:

 public class SettingsActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);

Fragment fragment = new SettingsScreen();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
if (savedInstanceState == null) {
    fragmentTransaction.add(R.id.settings, fragment, "settings_fragment");
    fragmentTransaction.commit();
} else {
    fragment = getSupportFragmentManager().findFragmentByTag("settings_fragment");

}
}

public static class SettingsScreen extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings_screen);
    SwitchPreference switchPreference = (SwitchPreference) findPreference("");
    switchPreference.setEnabled(false);
}
}
}

The error I am getting is this line: Fragment fragment = new SettingsScreen();



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here