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 8337571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:20:20+00:00 2026-06-09T04:20:20+00:00

I have created a custom listview which has Image + Text + checkbox. How

  • 0

I have created a custom listview which has Image + Text + checkbox. How to detect selecting/ unselecting of the check box. I tried onItemClick() but it won’t get called. Have I used it in correctly?

 class PInfo {
    String appname = "";
    String pname = "";
    Drawable 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;
        //newInfo.icon = app.icon;
        //Drawable dd = activity.getResources().getDrawable(app.icon);
        newInfo.icon = app.loadIcon(getPackageManager());

        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);


       //Here is where I have put it currently..

    listview.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub
            PInfo newInfo = (PInfo) listview.getItemAtPosition(arg2);
            System.out.println(newInfo.appname);
        }
    });
}



@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 = inflater.inflate(R.layout.listrow, arg2,false);

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


    PInfo pinfo = installedApps.get(arg0);

        tv.setText(""+pinfo.appname);
        iv.setImageDrawable(pinfo.icon);



    return customView;


}

}

Where should I add this code(if this is the right listner),

listview.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub
            PInfo newInfo = (PInfo) listview.getItemAtPosition(arg2);
            System.out.println(newInfo.appname);
        }
    });

Thanks..

  • 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-09T04:20:21+00:00Added an answer on June 9, 2026 at 4:20 am

    Write the code inside getView

    @Override
    public View getView(int arg0, View arg1, ViewGroup arg2) {
    // TODO Auto-generated method stub
    
    
    View  customView = inflater.inflate(R.layout.listrow, arg2,false);
    
    ImageView iv = (ImageView)customView.findViewById(R.id.imageView1);
    TextView tv= (TextView) customView.findViewById(R.id.textView2);
    CheckBox cb= (CheckBox)customView.findViewById(R.id.checkBox1);
    
    cb.setOnCheckedChangeListener(new OnCheckedChangeListener()
    {
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
    {
        if ( isChecked )
        {
            // perform logic
        }
    
    }
    });
    }
    
    
    PInfo pinfo = installedApps.get(arg0);
    
        tv.setText(""+pinfo.appname);
        iv.setImageDrawable(pinfo.icon);
    
    
    
    return customView;
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created custom cell in which there are n number of image views.
I have one listview.which contain one image ,text and one button .i had creted
I have a ListView which I've created a custom view for each row. My
HI Guyz i have created a sectioned custom listview using baseadapter its working fine
I have created a custom list view, each row has it's own custom selector,
I have created a custom tab layout which look like this,I want to make
I created a ListView with a custom layout for each view. I have several
I have a listview in which i wanted to have custom typeface e.g. Arial.
I have created a custom listview and adapter by extending BaseAdapter. Every time I
I have created a custom listview that have one webview per element. My problem

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.