Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try this:</p> <pre><code>package com.sliit.droidman.thirdpartyapplist; import com.sliit.droidman.R; import android.app.Activity; import android.graphics.drawable.Drawable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; public class ListViewAdapter extends BaseAdapter { Activity context; String title[]; String description[]; Drawable icon[]; public ListViewAdapter(Activity context, String[] title, String[] description , Drawable[] ico) { super(); this.context = context; this.title = title; this.description = description; this.icon = ico; } public int getCount() { // TODO Auto-generated method stub return title.length; } public Object getItem(int position) { // TODO Auto-generated method stub return null; } public long getItemId(int position) { // TODO Auto-generated method stub return 0; } //You have to overide the getView method @Override public View getView(int position, View convertView, ViewGroup parent) { //added row, to convert view View row = convertView; ViewHolder holder; if (convertView == null) { //added casting to the context LayoutInflater inflater = ((Activity)this.context).getLayoutInflater(); //made changes here row = inflater.inflate(R.layout.listitem_row, parent, false); holder = new ViewHolder(); holder.txtViewTitle = (TextView) convertView.findViewById(R.id.appname); holder.txtViewDescription = (TextView) convertView.findViewById(R.id.packagename); holder.image = (ImageView) convertView.findViewById(R.id.avatar); row.setTag(holder); } else { //added row holder = (ViewHolder) row.getTag(); } holder.txtViewTitle.setText(title[position]); holder.txtViewDescription.setText(description[position]); holder.image.setImageDrawable(icon[position]); //changed to row return row; } } static class ViewHolder { TextView txtViewTitle; TextView txtViewDescription; ImageView image; } </code></pre> <p>Basically, I created a static ViewHolder class outside the class of your listadapter, and made couple other minor changes, including overriding your getView method. I left comments where I made changes. Let me know if this works! Hope this helps! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload