I tried to create custom_row with an image and title in it. For this I created a new class 'MyClass' and used ArrayAdapter<MyClass>. But it is showing error in CustomAdapter.java at 'myimage.setImageResource(singlechar.imgs);' last but one line. Can anyone please tell what the error is and the solution.

CustomAdapter.java

package com.example.dell.mylistview;


import android.content.Context;
import android.view.La


youtInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

public class CustomAdapter extends ArrayAdapter{

    public CustomAdapter(Context context, ArrayList chars) {
        super(context, R.layout.custom_view, chars);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater myinflater = LayoutInflater.from(getContext());
        View customview = myinflater.inflate(R.layout.custom_view, parent,false);

        MyClass singlechar = getItem(position);
        TextView mytext = (TextView)customview.findViewById(R.id.mytext);
        ImageView myimage = (ImageView)customview.findViewById(R.id.myimage);
        mytext.setText(singlechar.chars);


        myimage.setImageResource(singlechar.imgs);
        return customview;
    }
}



MainActivity.java

package com.example.dell.mylistview;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;


import java.util.ArrayList;


public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ArrayList mychars = new ArrayList();
        mychars.add(new MyClass("harry", R.drawable.harry));
        mychars.add(new MyClass("hermione", R.drawable.hg));
        mychars.add(new MyClass("ron", R.drawable.ron));

        ListAdapter myadapter = new CustomAdapter(this, mychars);
        ListView mylist = (ListView)findViewById(R.id.mylist);
        mylist.setAdapter(myadapter);

        mylist.setOnItemClickListener(
                new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView parent, View view, int position, long id) {
                        String char1 = String.valueOf(parent.getItemAtPosition(position));
                        Toast.makeText(MainActivity.this, char1,Toast.LENGTH_SHORT).show();
                    }
                }
        );
    }

}