Skip to content Skip to sidebar Skip to footer

Problem With Spinner In Custom List Inside Activity Group

In my application, i have activity group in which i have a custom ListView with ImageView, TextView and a spinner. Error comes when i click on the spinner. here is the code.. final

Solution 1:

Try passing this.getPrent() to the MyCustomAdapter like this:

MyCustomAdapteradapter=newMyCustomAdapter(this.getPrent(), mylist, 0, null, null);

and make a Context variable in the MyCustomAdapter

privateclassMyCustomAdapterextendsSimpleAdapter{
        Context mContext;
        public MyCustomAdapter(Context context,List<?extends Map<String, ?>> data, int resource, String[] from, int[] to)
        {
            super(context, data, resource, from, to);
            mContext = context;
        }
        //getView implementation
}

and pass that mContext to the ArrayAdapter inside getView()

ArrayAdapter.createFromResource(mContext, R.array.number, android.R.layout.simple_spinner_item);

Post a Comment for "Problem With Spinner In Custom List Inside Activity Group"