1 /*
2  * Copyright (C) 2010 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  */
16 
17 package com.android.test.hwui;
18 
19 import android.app.Activity;
20 import android.os.Bundle;
21 import android.view.Gravity;
22 import android.view.LayoutInflater;
23 import android.view.View;
24 import android.widget.FrameLayout;
25 import android.widget.ImageView;
26 import android.widget.TextView;
27 import android.widget.ViewFlipper;
28 
29 @SuppressWarnings({"UnusedDeclaration"})
30 public class ViewFlipperActivity extends Activity {
31     @Override
onCreate(Bundle savedInstanceState)32     protected void onCreate(Bundle savedInstanceState) {
33         super.onCreate(savedInstanceState);
34 
35         final LayoutInflater inflater = getLayoutInflater();
36         final View widget = inflater.inflate(R.layout.widget, null);
37         widget.setLayoutParams(new FrameLayout.LayoutParams(180, 180, Gravity.CENTER));
38 
39         ViewFlipper flipper = (ViewFlipper) widget.findViewById(R.id.flipper);
40 
41         View view = inflater.inflate(R.layout.flipper_item, flipper, false);
42         flipper.addView(view);
43         ((ImageView) view.findViewById(R.id.widget_image)).setImageResource(R.drawable.sunset1);
44         ((TextView) view.findViewById(R.id.widget_text)).setText("This is a long line of text, "
45                 + "enjoy the wrapping and drawing");
46 
47         view = inflater.inflate(R.layout.flipper_item, flipper, false);
48         flipper.addView(view);
49         ((ImageView) view.findViewById(R.id.widget_image)).setImageResource(R.drawable.sunset3);
50         ((TextView) view.findViewById(R.id.widget_text)).setText("Another very long line of text, "
51                 + "enjoy the wrapping and drawing");
52 
53         FrameLayout layout = new FrameLayout(this);
54         layout.addView(widget);
55 
56         setContentView(layout);
57     }
58 }
59