Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Bitmap image = null;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- image = (Bitmap) getLastNonConfigurationInstance();
- if(bitmap == null){
- image = downloadImage();
- }
- setImage(bitmap);
- }
- @Override
- public Object onRetainNonConfigurationInstance() {
- return bitmap;
- }
- <activity android:name=".Explorer" android:label="@string/app_name"
- android:configChanges="orientation" android:launchMode="standard">
- </activity>
- @Override
- public void onConfigurationChanged(Configuration _newConfig){
- super.onConfigurationChanged(_newConfig);
- int height = getWindowManager().getDefaultDisplay().getHeight();
- int width = getWindowManager().getDefaultDisplay().getWidth();
- if(width > height){
- // layout for landscape
- }else{
- // layout for portrait
- }
- }
- void showDataView()
- {
- setContentView(mainView);
- currentView = mainView;
- }
- void showGraphView()
- {
- if(currentView == mainView){
- if(graphView == null){
- setContentView(R.layout.graphview);
- graphView = (GraphView)findViewById(R.id.graphview);
- }
- setContentView(graphView);
- currentView = graphView;
- graphView.setDataToPlot(DATA_TO_PLOT);
- graphView.clear();
- }
- }
- @Override
- public void onConfigurationChanged(Configuration _newConfig){
- super.onConfigurationChanged(_newConfig);
- int height = getWindowManager().getDefaultDisplay().getHeight();
- int width = getWindowManager().getDefaultDisplay().getWidth();
- if(width > height){
- showGraphView();
- }else{
- showDataView();
- }
- if(graphView != null) graphView.setGraphWidth(width);
- }
Add Comment
Please, Sign In to add comment