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
17package com.android.test.hwui;
18
19import android.app.Activity;
20import android.os.Bundle;
21import android.view.Gravity;
22import android.view.LayoutInflater;
23import android.view.View;
24import android.widget.FrameLayout;
25import android.widget.ImageView;
26import android.widget.TextView;
27import android.widget.ViewFlipper;
28
29@SuppressWarnings({"UnusedDeclaration"})
30public class ViewFlipperActivity extends Activity {
31    @Override
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