mercredi 20 septembre 2017

My app getting force closed after checking a checkbox

I have used this code to get check boxes in app list,it works fine but when we clicked on the box it forcefully closes the app the code is here

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;

    if (view == null) {
        LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = vi.inflate(R.layout.custom_row_layout, null);
    }


    ImageView icon = (ImageView) view.findViewById(R.id.icon);
    TextView text = (TextView) view.findViewById(R.id.text);

    CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkBox);

    final AppDetails item = data.get(position);

    text.setText(item.name);
    icon.setImageDrawable(item.icon);

    checkBox .setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                // Handle your conditions here

            }
        });


    return view;
}




Aucun commentaire:

Enregistrer un commentaire