i am sending array list items[x,y,z…] to the custom adapter. i want display items in listview. i can print all items using for loop(x,y,z…like).in side getview method i can pritem itemnames[possition] means it cannot print array list …
i try this code
public class CustomAdapter extends BaseAdapter{
public static ArrayList<String> arr=new ArrayList<String>();
public Context Context;
private LayoutInflater inflater;
HashMap<String, String> map = new HashMap<String, String>();
public CustomAdapter(Context context, ArrayList<String> arr) {
Context=context;
//inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// imageLoader=new ImageLoader(activity);
inflater=LayoutInflater.from(context);
arr=arr;
for(int i=0;i<arr.size();i++)
{
arr.get(i);
}
}
public int getCount() {
// TODO Auto-generated method stub
return arr.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View vi=convertView;
vi=inflater.inflate(R.layout.selecteditemlistview, null);
System.out.println(arr.get(position));
TextView text=(TextView)vi.findViewById(R.id.selectedtext);
text.setText(arr.get(position));
return vi;
}
}
where i done mistake please tell me…
You need to return
arraylist sizeingetCount()Method instead ofreturn 0.