当我使用这个costum布局给我的列表视图充气时,我的应用程序崩溃了我已经尝试了不同答案中的所有内容,但无法找到正确的答案......第一个是仅用特定视图的复选框来扩展视图...请帮助
package com.codiaq.launcher.alpha.Preferences;
public class SettingsAppearanceAdapter extends ArrayAdapter<FunctionsAp>{
Context context;
int layoutResourceId;
FunctionsAp data[] = null;
Class c;
SettingsHandler sh;
public SettingsAppearanceAdapter(Context context, int layoutResourceId, FunctionsAp[] data) {
super(context, layoutResourceId, data);
this.layoutResourceId = layoutResourceId;
this.context = context;
this.data = data;
sh = new SettingsHandler(context);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View row = convertView;
if(data[position].title.equals(context.getString(R.string.fullscreen))
|| data[position].title.equals(context.getString(R.string.black_statnav))
|| data[position].title.equals(context.getString(R.string.tint_background))){
HolderCheckbox holder = null;
if(row == null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(R.layout.list_with_checkbox, parent, false);
holder = new HolderCheckbox();
holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);
holder.txtDesc = (TextView)row.findViewById(R.id.textDesc);
holder.checkBox = (CheckBox)row.findViewById(R.id.checkBox);
if(position == 0){
holder.checkBox.setChecked(sh.getFullscreen());
}
if(position == 1){
holder.checkBox.setChecked(sh.getBlackStatNav());
}
if(position == 2){
holder.checkBox.setChecked(sh.getTintBackground());
}
holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton button, boolean checked)
{
// Cast it so we can access the public functions
SettingsActivityAppearance.checkboxSelected(checked, position);
}
});
row.setTag(holder);
}
else
{
holder = (HolderCheckbox) row.getTag();
}
FunctionsAp weather = data[position];
holder.txtTitle.setText(weather.title);
holder.txtDesc.setText(weather.description);
//holder.imgIcon.setImageResource(weather.icon);
return row;
}
else{
WeatherHolder holder = null;
if(row == null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new WeatherHolder();
// holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);
holder.txtDesc = (TextView)row.findViewById(R.id.textDesc);
row.setTag(holder);
}
else
{
holder = (WeatherHolder)row.getTag();
}
FunctionsAp weather = data[position];
holder.txtTitle.setText(weather.title);
holder.txtDesc.setText(weather.description);
//holder.imgIcon.setImageResource(weather.icon);
return row;
}
}
static class WeatherHolder
{
ImageView imgIcon;
TextView txtTitle;
TextView txtDesc;
}
static class HolderCheckbox{
TextView txtDesc;
TextView txtTitle;
CheckBox checkBox;
}