Last active
August 29, 2015 14:10
-
-
Save fnk0/0659680e7ab233d907a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/settingsFrag" | |
android:orientation="vertical" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
> | |
<FrameLayout | |
android:id="@+id/container" | |
android:layout_alignParentTop="true" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> | |
<!-- Your preff stuff goes here --> | |
</PreferenceScreen> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SettingsAcrivity extends ActionBarActivity { | |
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
if (item.getItemId() == android.R.id.home) { | |
finish(); | |
return true; | |
} | |
return super.onOptionsItemSelected(item); | |
} | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.settings_activity); | |
// Display the fragment as the main content. | |
getFragmentManager().beginTransaction() | |
.replace(R.id.container, new SettingsFragment()) | |
.commit(); | |
// use action bar here | |
ActionBar actionBar = getSupportActionBar(); | |
actionBar.setHomeButtonEnabled(true); | |
actionBar.setDisplayHomeAsUpEnabled(true); | |
} | |
public static class SettingsFragment extends PreferenceFragment { | |
@Override | |
public void onCreate(Bundle paramBundle) { | |
super.onCreate(paramBundle); | |
addPreferencesFromResource(R.xml.my_pref); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment