Home | History | Annotate | Download | only in listview
      1 /*
      2  * Copyright (C) 2007 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.listview;
     18 
     19 import android.content.Context;
     20 import android.view.View;
     21 import android.view.ViewGroup;
     22 import android.widget.Button;
     23 import android.widget.LinearLayout;
     24 import android.widget.TextView;
     25 import android.util.InternalSelectionView;
     26 import android.util.ListScenario;
     27 
     28 /**
     29  * Each item is an internal selection view, a button, and some filler
     30  */
     31 public class ListItemISVAndButton extends ListScenario {
     32 
     33 
     34     @Override
     35     protected void init(Params params) {
     36         params.setItemScreenSizeFactor(2.0)
     37                 .setNumItems(3)
     38                 .setItemsFocusable(true);
     39     }
     40 
     41     @Override
     42     protected View createView(int position, ViewGroup parent, int desiredHeight) {
     43         Context context = parent.getContext();
     44 
     45         final LinearLayout ll = new LinearLayout(context);
     46         ll.setOrientation(LinearLayout.VERTICAL);
     47 
     48         final InternalSelectionView isv = new InternalSelectionView(context, 8, "ISV postion " + position);
     49         isv.setLayoutParams(new LinearLayout.LayoutParams(
     50                 ViewGroup.LayoutParams.MATCH_PARENT,
     51                 desiredHeight - 240));
     52         ll.addView(isv);
     53 
     54         final LinearLayout.LayoutParams buttonLp =
     55                 new LinearLayout.LayoutParams(
     56                         ViewGroup.LayoutParams.MATCH_PARENT,
     57                         40);
     58         final Button topButton = new Button(context);
     59         topButton.setLayoutParams(
     60                 buttonLp);
     61         topButton.setText("button " + position + ")");
     62         ll.addView(topButton);
     63 
     64         final TextView filler = new TextView(context);
     65         filler.setLayoutParams(new LinearLayout.LayoutParams(
     66                 ViewGroup.LayoutParams.MATCH_PARENT,
     67                 200));
     68         filler.setText("filler");
     69         ll.addView(filler);
     70 
     71 
     72         return ll;
     73     }
     74 
     75 }
     76