Created
November 14, 2015 15:51
-
-
Save DevPicon/f35afda5d2b9d28fa715 to your computer and use it in GitHub Desktop.
Observemos estos tres activities, en un primer momento solo los dos primeros comparten la misma clase padre y cuentan con elementos comunes dentro de su función onCreate()
This file contains hidden or 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 MainActivity extends AppCompatActivity implements PlaceListFragment.Callback { | |
private boolean mTwoPane = false; | |
private String LOG_TAG = MainActivity.class.getSimpleName(); | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
if (findViewById(R.id.place_detail_container) != null) { | |
mTwoPane = true; | |
if (savedInstanceState == null) { | |
getSupportFragmentManager().beginTransaction() | |
.add(R.id.place_detail_container, new PlaceDetailFragment()) | |
.commit(); | |
} | |
} else { | |
mTwoPane = false; | |
} | |
// Show home icon | |
ActionBar actionBar = getSupportActionBar(); | |
actionBar.setDisplayShowHomeEnabled(true); | |
PlaceSyncAdapter.initializeSyncAdapter(this); | |
} |
This file contains hidden or 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 PlaceDetailActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_place_detail); | |
if (savedInstanceState == null) { | |
long placeId = getIntent().getLongExtra(PlaceDetailFragment.PLACE_KEY, -1); | |
Bundle arguments = new Bundle(); | |
arguments.putLong(PlaceDetailFragment.PLACE_KEY, placeId); | |
PlaceDetailFragment fragment = new PlaceDetailFragment(); | |
fragment.setArguments(arguments); | |
getSupportFragmentManager().beginTransaction() | |
.add(R.id.place_detail_container, fragment) | |
.commit(); | |
} | |
} |
This file contains hidden or 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 SettingsActivity extends PreferenceActivity implements Preference.OnPreferenceChangeListener { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
addPreferencesFromResource(R.xml.pref_general); | |
//bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_location_default))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment