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