Demo0.java revision faebd8f0795b7d275fb4e503533c8c0c4a9acc21
1/* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package com.android.transitiontests; 17 18import android.app.Activity; 19import android.content.Context; 20import android.os.Bundle; 21import android.view.LayoutInflater; 22import android.view.View; 23import android.view.ViewGroup; 24import com.android.transitiontest.R; 25 26 27public class Demo0 extends Activity { 28 29 private static final int SEARCH_SCREEN = 0; 30 private static final int RESULTS_SCREEN = 1; 31 ViewGroup mSceneRoot; 32 static int mCurrentScene; 33 34 @Override 35 public void onCreate(Bundle savedInstanceState) { 36 super.onCreate(savedInstanceState); 37 setContentView(R.layout.search_screen); 38 39 View container = (View) findViewById(R.id.container); 40 mSceneRoot = (ViewGroup) container.getParent(); 41 42 mCurrentScene = SEARCH_SCREEN; 43 } 44 45 public void sendMessage(View view) { 46 if (mCurrentScene == RESULTS_SCREEN) { 47 mSceneRoot.removeAllViews(); 48 LayoutInflater inflater = (LayoutInflater) 49 getSystemService(Context.LAYOUT_INFLATER_SERVICE); 50 inflater.inflate(R.layout.search_screen, mSceneRoot); 51 mCurrentScene = SEARCH_SCREEN; 52 } else { 53 mSceneRoot.removeAllViews(); 54 LayoutInflater inflater = (LayoutInflater) 55 getSystemService(Context.LAYOUT_INFLATER_SERVICE); 56 inflater.inflate(R.layout.results_screen, mSceneRoot); 57 mCurrentScene = RESULTS_SCREEN; 58 } 59 } 60} 61