Home | History | Annotate | Download | only in list
      1 /*
      2  * Copyright (C) 2014 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.cts.verifier.projection.list;
     18 
     19 import android.content.Context;
     20 import android.os.Bundle;
     21 import android.view.Display;
     22 import android.view.View;
     23 import android.widget.ArrayAdapter;
     24 import android.widget.ListView;
     25 
     26 import com.android.cts.verifier.R;
     27 import com.android.cts.verifier.projection.ProjectedPresentation;
     28 
     29 import java.util.ArrayList;
     30 
     31 /**
     32  * Render a list view that scrolls
     33  */
     34 public class ListPresentation extends ProjectedPresentation {
     35     private ArrayList<String> mItemList = new ArrayList<String>();
     36     private static final int NUM_ITEMS = 50; // Enough to make the list scroll
     37 
     38     /**
     39      * @param outerContext
     40      * @param display
     41      */
     42     public ListPresentation(Context outerContext, Display display) {
     43         super(outerContext, display);
     44     }
     45 
     46     @Override
     47     protected void onCreate(Bundle savedInstanceState) {
     48         super.onCreate(savedInstanceState);
     49         View view = getLayoutInflater().inflate(R.layout.pla_list, null);
     50         setContentView(view);
     51 
     52         for (int i = 0; i < NUM_ITEMS; ++i) {
     53             mItemList.add("Item #" + (1 + i));
     54         }
     55 
     56         ListView listView = (ListView) view.findViewById(R.id.pla_list);
     57 
     58         listView.setAdapter(new ArrayAdapter<String>(getContext(),
     59                 android.R.layout.simple_list_item_1, mItemList));
     60     }
     61 
     62 }
     63