| 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.graphics.drawable.Drawable; |
| 21 |
import android.os.Bundle; |
| 22 |
import android.view.LayoutInflater; |
| 23 |
import android.view.View; |
| 24 |
import android.view.ViewGroup; |
| 25 |
import android.widget.ArrayAdapter; |
| 26 |
import android.widget.ImageView; |
| 27 |
import android.widget.StackView; |
| 28 |
import android.widget.TextView; |
| 29 |
|
| 30 |
@SuppressWarnings({"UnusedDeclaration"}) |
| 31 |
public class StackActivity extends Activity { |
| 32 |
@Override |
| 33 |
protected void onCreate(Bundle savedInstanceState) { |
| 34 |
super.onCreate(savedInstanceState); |
| 35 |
|
| 36 |
setContentView(R.layout.stack); |
| 37 |
|
| 38 |
StackView stack = findViewById(R.id.stack_view); |
| 39 |
stack.setAdapter(new ArrayAdapter<Drawable>(this, android.R.layout.simple_list_item_1, |
| 40 |
android.R.id.text1, new Drawable[] { |
| 41 |
getResources().getDrawable(R.drawable.sunset1), |
| 42 |
getResources().getDrawable(R.drawable.sunset2), |
| 43 |
}) { |
| 44 |
@Override |
| 45 |
public View getView(int position, View convertView, ViewGroup parent) { |
| 46 |
View item = convertView; |
| 47 |
if (item == null) { |
| 48 |
item = LayoutInflater.from(getContext()).inflate( |
| 49 |
R.layout.stack_item, null, false); |
| 50 |
} |
| 51 |
((ImageView) item.findViewById(R.id.textview_icon)).setImageDrawable( |
| 52 |
getItem(position % getCount())); |
| 53 |
((TextView) item.findViewById(R.id.mini_text)).setText("" + position); |
| 54 |
return item; |
| 55 |
} |
| 56 |
}); |
| 57 |
stack.setDisplayedChild(0); |
| 58 |
} |
| 59 |
} |