Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8325695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:31:32+00:00 2026-06-09T00:31:32+00:00

I have created a custom listview. It has a image, text and a checkbox

  • 0

I have created a custom listview. It has a image, text and a checkbox and when I try to set a value for the above I get a NUll Pointer Exception. How ever if I don’t set a value I get the default list…why is this happening?

class PInfo {
    String appname = "";
    String pname = "";
    String versionName = "";
    int versionCode = 0;
    int icon;
 }

 public class InstalledApps extends Activity{

    private static LayoutInflater inflater=null;
private ListView listview;
private Activity activity;

List<PInfo> installedApps = new ArrayList<PInfo>();

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.applist);

    activity = this;
    listview = (ListView)findViewById(R.id.listView1);

    PackageManager pm = getPackageManager();
    List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

    for(ApplicationInfo app : packages) {

        PInfo newInfo = new PInfo();
            newInfo.appname = (String) app.loadLabel(pm);
            newInfo.pname = app.packageName;

        if((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 1){             
            installedApps.add(newInfo);

        } else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
            installedApps.add(newInfo);

        } else {

            installedApps.add(newInfo); 
        }
    }

    InstalledAppsAdapter iap = new InstalledAppsAdapter(this, installedApps);
listview.setAdapter(iap);

}
}

   class InstalledAppsAdapter extends BaseAdapter{

private Activity activity;
private static LayoutInflater inflater=null;
List<PInfo> installedApps = new ArrayList<PInfo>();
ListView listview; 

public InstalledAppsAdapter(Activity a, List<PInfo> b) {

    // TODO Auto-generated constructor stub
    installedApps = b;
    activity = a;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    listview = (ListView)activity.findViewById(R.id.listView1);
}


@Override
public int getCount() {
    // TODO Auto-generated method stub
    return installedApps.size();
}

@Override
public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return arg0;
}

@Override
public long getItemId(int arg0) {
    // TODO Auto-generated method stub
    return arg0;
}

@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
    // TODO Auto-generated method stub

    View customView = arg1;
    ViewHolder holder;

    if(arg1 == null){
        customView = inflater.inflate(R.layout.listrow, null);


    holder = new ViewHolder();
    holder.iv = (ImageView)customView.findViewById(R.id.imageView1);
    holder.tv = (TextView) customView.findViewById(R.id.textView2);
    holder.cb = (CheckBox)customView.findViewById(R.id.checkBox1);

    }else{
        holder = (ViewHolder)customView.getTag();
    }

    PInfo pinfo = installedApps.get(arg0);

    holder.tv.setText(""+pinfo.appname);

    return customView;
}

static class ViewHolder{

    ImageView iv;
    CheckBox cb;
    TextView tv;

}

}

EDIT : aded the full source

It looks like as if findViewById(R.id.textView1) is returning null..why??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:31:33+00:00Added an answer on June 9, 2026 at 12:31 am

    I think you use *“textView1”*named id in anyother ui. Change the id name of the TextView and use it.

    Check this code

    public View getView(int arg0, View arg1, ViewGroup arg2) {
        // TODO Auto-generated method stub
    
    
        View  customView = inflater.inflate(R.layout.listrow, parent,false);
    
        ImageView iv = (ImageView)customView.findViewById(R.id.imageView1);
        TextView tv= (TextView) customView.findViewById(R.id.textView1);
        CheckBox cb= (CheckBox)customView.findViewById(R.id.checkBox1);
    
    
        PInfo pinfo = installedApps.get(arg0);
       tv.setText(""+pinfo.appname);//If u comment this line it works
    
        return customView;
    }
    

    Use this code instead of that. May it solves your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom listview which has Image + Text + checkbox. How
We have created custom listview by using the Base adapter. List view contains Text
I have created a custom list view, each row has it's own custom selector,
HI Guyz i have created a sectioned custom listview using baseadapter its working fine
I have created custom cell in which there are n number of image views.
I have created a custom listview using adapter. Each row of the list view
I have a ListView which I've created a custom view for each row. My
I have created custom listview in that have list of textview & list of
Actually I have created a custom ListView . I want to add items to
I have created a custom ArrayAdapter to display data within ListView items from an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.