| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 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 |
| 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 |
} |