-4

Hi have an custom listview with following snippet.
The problem is the app get crashed when i run the code Here is my code

class MyAdupter extends ArrayAdapter<String>{
     Context context; 
     String[] title ; 
     String[] description; 
     int[] images; 
     public MyAdupter(Context context, String[] title, String[] description, int[] images) {
        super(context, R.layout.my_simple_row,title);
        this.context = context; 
        this.title = title; 
        this.description = description; 
    } 
    @Override 
    public View getView(int position, View convertView, ViewGroup parent) {
        Layoutlnflater inflater = (Layoutlnflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
        View row = inflater.inflate(R.layout.my_simple_row, parent, false); 
        ImageView imageView = (ImageView) row.findViewById (R.id.imageViewl); 
        TextView textTitle = (TextView) row.findViewById (R.id.textViewl); 
        TextView textDescription = (TextView) row.findViewById(R.id.textView2);   

        imageView.setImageResource(images[position]); 
        textTitle.setText(title[position]); 
        textDescription.setText(description[position]); 
        return row; 
    }
}
Quick learner
  • 6,975
  • 2
  • 30
  • 44
Bhringesh
  • 29
  • 1
  • 5

2 Answers2

7

Well You forgot to assign value to images array int the constructor

this.images=image;

try it !!!

Quick learner
  • 6,975
  • 2
  • 30
  • 44
0

Forgotten Assigning

Use in constructor this.images=image; constructor code becomes

public MyAdupter(Context context,String... title,String... description,int... images) {
super(context, R.layout.my_simple_row,title);
this.context = context;
this.title = title;
this.description = description;
this.images = images;
}
Abhishek
  • 3,156
  • 2
  • 14
  • 28