Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2008 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 android.widget.cts;
     18 
     19 import android.app.Activity;
     20 import android.os.Bundle;
     21 import android.view.ViewGroup.LayoutParams;
     22 import android.widget.ArrayAdapter;
     23 import android.widget.ListView;
     24 import android.widget.cts.R;
     25 
     26 import java.util.ArrayList;
     27 import java.util.List;
     28 
     29 /**
     30  * A minimal application for AdapterView test.
     31  */
     32 public class AdapterViewCtsActivity extends Activity {
     33     private ListView mView;
     34 
     35     /**
     36      * Called with the activity is first created.
     37      */
     38     @Override
     39     public void onCreate(Bundle savedInstanceState) {
     40         super.onCreate(savedInstanceState);
     41         mView = new ListView(this);
     42         mView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
     43                 LayoutParams.WRAP_CONTENT));
     44         setContentView(mView);
     45     }
     46 
     47     public ListView getListView() {
     48         return mView;
     49     }
     50 
     51     public ArrayAdapter<String> getArrayAdapter() {
     52         final List<String> list = new ArrayList<String>();
     53         for (int i = 0; i < 4; i++) {
     54             list.add("test:" + i);
     55         }
     56         return new ArrayAdapter<String>(this, R.layout.adapterview_layout, list);
     57     }
     58 }
     59