Android Inside Adapter getView not Called?

Geting List Size is 46. i am getting all the value inside constrator . getView is not calling,

My Code Below,

  public class Atom_1_Adapter extends BaseAdapter {

                private Activity activity;
                    List<MsgStandard> msgList1=new ArrayList<MsgStandard>();
                private LayoutInflater inflater=null;
                ImageLoader imageLoader;    
                int size=0;
                String tag="Atom_1_Adapter";

            public Atom_1_Adapter(Activity activity, List<MsgStandard> msgList1) {
                    this.activity = activity;
  this.msgList1 = msgList1
                    size=this.msgList1.size();
                    inflater = (LayoutInflater)this.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    imageLoader=new ImageLoader(activity);
                }

        @Override
            public int getCount() {
                return size;
            }

            @Override
            public Object getItem(int position) {
                return position;
            }

            @Override
            public long getItemId(int position) {
                return position;
            }

        class ViewHolder{
                ImageView image1,image2;
        }
            @Override
            public View getView(final int position, View convertView, ViewGroup parent) {
                System.out.println("enter get view--->>>>>>");
                View vi=convertView;
                ViewHolder holder=new ViewHolder();
                try{
                    vi=inflater.inflate(R.layout.homepagelist_1_adapter,null);

        //here my layout declaration


        vi.setTag(holder);

        //here set value for TextView,ImageView... etc

        return vi;

        }catch{}
        }
        }

Thanks,

Answers


Try this.

Change you constructor code .

public Atom_1_Adapter(Activity activity, List<MsgStandard> msgList1) 
{
   this.activity = activity;
   this.msgList1 = msgList1
   size=this.msgList1.size();
   inflater = (LayoutInflater)this.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   imageLoader=new ImageLoader(activity);
}

Note : this.msgList1.size() is consider as class variable which you declare in your Adapter Class . So if you want to find the size of List which is passed in function then you need to remove this infront of msgList1.size() in your constructor. And Assign this.msgList1 = msgList1; . Look My Code

public View getView(int position, View convertView, ViewGroup parent) 
{
    ViewHolder holder;

    if (convertView == null) 
    {
        convertView = mInflater.inflate(R.layout.menu_row, null);
        holder = new ViewHolder();

        holder.textViewMenuName = (TextView)convertView.findViewById(R.id.textViewMenuName);
        convertView.setTag(holder);
    }
    else 
    {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.textViewMenuName.setText("Test");
            return convertView;
}

Need Your Help

Best technique to print text to console

java oop console

I am writing a command line tool that performs a number of tests to our servers and reports an output to screen.

iPhone Development - Learning materials

iphone

I am starting with iPhone development and stuck with finding a good, up-to-date book or website.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.