This is my code:
path = new ArrayList<String>();
adapter = new PathAdapter(this, path);
path_list.setAdapter(adapter);
And then, in a press of a button i inserted another string:
this is to add and update the list
path.add("new string");
adapter.notifyDataSetChanged();
and in my adapter:
if(view == null){
view = inflater.inflate(R.layout.pics_row, parent, false);
holder = new ViewHolder();
holder.ivPath = (TextView) view.findViewById(R.id.path);
view.setTag(holder);
Log.e("view", "null");
}else{
holder = (ViewHolder) view.getTag();
Log.e("view" , "not null");
}
The logs is for me to know which condition it went. The problem is that, it called the getView() trice. Why? I only inserted 1 item.
logcat:
10-02 18:37:56.332 22783-22783/smartminds.com.ci E/view﹕ null
10-02 18:37:56.335 22783-22783/smartminds.com.ci E/view﹕ not null
10-02 18:37:56.407 22783-22783/smartminds.com.ci E/view﹕ not null