SetupWizardListLayout.java revision 9f9367672191190f903955d09a4314d40869acc6
195af12dac219e6945bab6142ea3a4099077314aaMaurice Lam/* 295af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * Copyright (C) 2015 The Android Open Source Project 395af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * 495af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * Licensed under the Apache License, Version 2.0 (the "License"); 595af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * you may not use this file except in compliance with the License. 695af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * You may obtain a copy of the License at 795af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * 895af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * http://www.apache.org/licenses/LICENSE-2.0 995af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * 1095af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * Unless required by applicable law or agreed to in writing, software 1195af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * distributed under the License is distributed on an "AS IS" BASIS, 1295af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1395af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * See the License for the specific language governing permissions and 1495af12dac219e6945bab6142ea3a4099077314aaMaurice Lam * limitations under the License. 1595af12dac219e6945bab6142ea3a4099077314aaMaurice Lam */ 1695af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 1795af12dac219e6945bab6142ea3a4099077314aaMaurice Lampackage com.android.setupwizardlib; 1895af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 199f9367672191190f903955d09a4314d40869acc6Maurice Lamimport android.annotation.TargetApi; 2095af12dac219e6945bab6142ea3a4099077314aaMaurice Lamimport android.content.Context; 219f9367672191190f903955d09a4314d40869acc6Maurice Lamimport android.os.Build.VERSION_CODES; 2295af12dac219e6945bab6142ea3a4099077314aaMaurice Lamimport android.util.AttributeSet; 2395af12dac219e6945bab6142ea3a4099077314aaMaurice Lamimport android.view.LayoutInflater; 2495af12dac219e6945bab6142ea3a4099077314aaMaurice Lamimport android.view.View; 2595af12dac219e6945bab6142ea3a4099077314aaMaurice Lamimport android.widget.ListAdapter; 2695af12dac219e6945bab6142ea3a4099077314aaMaurice Lamimport android.widget.ListView; 2795af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 2895af12dac219e6945bab6142ea3a4099077314aaMaurice Lampublic class SetupWizardListLayout extends SetupWizardLayout { 2995af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 3095af12dac219e6945bab6142ea3a4099077314aaMaurice Lam private static final String TAG = "SetupWizardListLayout"; 3195af12dac219e6945bab6142ea3a4099077314aaMaurice Lam private ListView mListView; 3295af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 3395af12dac219e6945bab6142ea3a4099077314aaMaurice Lam public SetupWizardListLayout(Context context) { 349f9367672191190f903955d09a4314d40869acc6Maurice Lam super(context); 3595af12dac219e6945bab6142ea3a4099077314aaMaurice Lam } 3695af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 3795af12dac219e6945bab6142ea3a4099077314aaMaurice Lam public SetupWizardListLayout(Context context, int template) { 389f9367672191190f903955d09a4314d40869acc6Maurice Lam super(context, template); 3995af12dac219e6945bab6142ea3a4099077314aaMaurice Lam } 4095af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 4195af12dac219e6945bab6142ea3a4099077314aaMaurice Lam public SetupWizardListLayout(Context context, AttributeSet attrs) { 429f9367672191190f903955d09a4314d40869acc6Maurice Lam super(context, attrs); 4395af12dac219e6945bab6142ea3a4099077314aaMaurice Lam } 4495af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 459f9367672191190f903955d09a4314d40869acc6Maurice Lam @TargetApi(VERSION_CODES.HONEYCOMB) 4695af12dac219e6945bab6142ea3a4099077314aaMaurice Lam public SetupWizardListLayout(Context context, AttributeSet attrs, int defStyleAttr) { 479f9367672191190f903955d09a4314d40869acc6Maurice Lam super(context, attrs, defStyleAttr); 4895af12dac219e6945bab6142ea3a4099077314aaMaurice Lam } 4995af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 509f9367672191190f903955d09a4314d40869acc6Maurice Lam @TargetApi(VERSION_CODES.HONEYCOMB) 5195af12dac219e6945bab6142ea3a4099077314aaMaurice Lam public SetupWizardListLayout(Context context, int template, AttributeSet attrs, 5295af12dac219e6945bab6142ea3a4099077314aaMaurice Lam int defStyleAttr) { 5395af12dac219e6945bab6142ea3a4099077314aaMaurice Lam super(context, template, attrs, defStyleAttr); 5495af12dac219e6945bab6142ea3a4099077314aaMaurice Lam } 5595af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 5695af12dac219e6945bab6142ea3a4099077314aaMaurice Lam @Override 5795af12dac219e6945bab6142ea3a4099077314aaMaurice Lam protected View onInflateTemplate(LayoutInflater inflater, int template) { 5895af12dac219e6945bab6142ea3a4099077314aaMaurice Lam if (template == 0) { 5995af12dac219e6945bab6142ea3a4099077314aaMaurice Lam template = R.layout.suw_list_template; 6095af12dac219e6945bab6142ea3a4099077314aaMaurice Lam } 6195af12dac219e6945bab6142ea3a4099077314aaMaurice Lam return inflater.inflate(template, this, false); 6295af12dac219e6945bab6142ea3a4099077314aaMaurice Lam } 6395af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 6495af12dac219e6945bab6142ea3a4099077314aaMaurice Lam @Override 6595af12dac219e6945bab6142ea3a4099077314aaMaurice Lam protected void onTemplateInflated() { 6695af12dac219e6945bab6142ea3a4099077314aaMaurice Lam mListView = (ListView) findViewById(android.R.id.list); 6795af12dac219e6945bab6142ea3a4099077314aaMaurice Lam } 6895af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 6995af12dac219e6945bab6142ea3a4099077314aaMaurice Lam @Override 7095af12dac219e6945bab6142ea3a4099077314aaMaurice Lam protected int getContainerId() { 7195af12dac219e6945bab6142ea3a4099077314aaMaurice Lam return android.R.id.list; 7295af12dac219e6945bab6142ea3a4099077314aaMaurice Lam } 7395af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 7495af12dac219e6945bab6142ea3a4099077314aaMaurice Lam public ListView getListView() { 7595af12dac219e6945bab6142ea3a4099077314aaMaurice Lam return mListView; 7695af12dac219e6945bab6142ea3a4099077314aaMaurice Lam } 7795af12dac219e6945bab6142ea3a4099077314aaMaurice Lam 7895af12dac219e6945bab6142ea3a4099077314aaMaurice Lam public void setAdapter(ListAdapter adapter) { 7995af12dac219e6945bab6142ea3a4099077314aaMaurice Lam getListView().setAdapter(adapter); 8095af12dac219e6945bab6142ea3a4099077314aaMaurice Lam } 8195af12dac219e6945bab6142ea3a4099077314aaMaurice Lam} 82