10a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy/* 20a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * Copyright (C) 2010 The Android Open Source Project 30a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * 40a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 50a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * you may not use this file except in compliance with the License. 60a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * You may obtain a copy of the License at 70a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * 80a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * http://www.apache.org/licenses/LICENSE-2.0 90a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * 100a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * Unless required by applicable law or agreed to in writing, software 110a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * distributed under the License is distributed on an "AS IS" BASIS, 120a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * See the License for the specific language governing permissions and 140a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy * limitations under the License. 150a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy */ 160a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy 17f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guypackage com.android.test.hwui; 180a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy 190a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guyimport android.app.Activity; 200a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guyimport android.graphics.drawable.Drawable; 210a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guyimport android.os.Bundle; 221d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guyimport android.view.LayoutInflater; 230a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guyimport android.view.View; 240a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guyimport android.view.ViewGroup; 250a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guyimport android.widget.ArrayAdapter; 260a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guyimport android.widget.ImageView; 270a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guyimport android.widget.StackView; 281d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guyimport android.widget.TextView; 290a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy 300a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy@SuppressWarnings({"UnusedDeclaration"}) 310a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guypublic class StackActivity extends Activity { 320a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy @Override 330a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy protected void onCreate(Bundle savedInstanceState) { 340a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy super.onCreate(savedInstanceState); 350a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy 361d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guy setContentView(R.layout.stack); 371d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guy 381d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guy StackView stack = (StackView) findViewById(R.id.stack_view); 390a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy stack.setAdapter(new ArrayAdapter<Drawable>(this, android.R.layout.simple_list_item_1, 400a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy android.R.id.text1, new Drawable[] { 410a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy getResources().getDrawable(R.drawable.sunset1), 420a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy getResources().getDrawable(R.drawable.sunset2), 430a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy }) { 440a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy @Override 450a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy public View getView(int position, View convertView, ViewGroup parent) { 461d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guy View item = convertView; 471d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guy if (item == null) { 481d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guy item = LayoutInflater.from(getContext()).inflate( 491d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guy R.layout.stack_item, null, false); 500a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy } 511d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guy ((ImageView) item.findViewById(R.id.textview_icon)).setImageDrawable( 521d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guy getItem(position % getCount())); 531d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guy ((TextView) item.findViewById(R.id.mini_text)).setText("" + position); 541d83e1981c8b89da93dff37a4f8b2b1ad8480b44Romain Guy return item; 550a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy } 560a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy }); 570a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy stack.setDisplayedChild(0); 580a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy } 590a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy} 60