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

  • Home
  • SEARCH
  • 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 8387855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:19:44+00:00 2026-06-09T18:19:44+00:00

1.when I running this app,it shows the package name and ico in the listview,but

  • 0

1.when I running this app,it shows the package name and ico in the listview,but it is abnormal.
The item is reduplicate.can anybody help me point it out what’s wrong with my code?

/**show the packageinfo.*/
public class MainForm extends Activity {
    PackageManager pm; 
    ListView applist; 
    List<PackageInfo> appInfo; 
    ImageView itemImage; 
    TextView appName;  

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        applist = (ListView) findViewById(R.id.applist);
        pm = getPackageManager();
        appInfo = (List<PackageInfo>) pm.getInstalledPackages(0);
        applist.setAdapter(new MyAdapter());
    }

    private class MyAdapter extends BaseAdapter {
        private LayoutInflater mInflater;       
        public MyAdapter() {
            // TODO Auto-generated constructor stub
            this.mInflater=LayoutInflater.from(MainForm.this);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {

            View v = null;
            if (convertView == null) {
                LayoutInflater li =mInflater;
                v = li.inflate(R.layout.layout_applist, null);

                itemImage = (ImageView) v.findViewById(R.id.item_icon);//get the imageview
                appName = (TextView)v.findViewById(R.id.packname);//get the textview
            } else {
                v = convertView;
            }

            itemImage.setBackgroundDrawable(((PackageInfo)getItem      (position)).applicationInfo.loadIcon(pm)); 
            appName.setText(((PackageInfo)getItem(position)).applicationInfo.loadLabel(pm).toString()); 

            return v;
        }

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return appInfo.size();
        }
        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return appInfo.get(position);
        }
        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }
    }
}
  • 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-09T18:19:46+00:00Added an answer on June 9, 2026 at 6:19 pm

    from the top of my head, it looks like you’ve defined v twice then it returns v hence duplicated list.

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

Sidebar

Related Questions

I am getting this error While running this LoadError: Expected /home/user/Desktop/Tripurari/myapp/app/models/host.rb to define Host##
I have a web application running on Windows IIS. This app has a database
I have this RoR app that calls to RAILS_ROOT. When running it using rails
i have an asp.net website http://www.site.com . This web app is also running on
This works on the iPhone BTW (Both running iOS 5.1) My app freezes when
Moving rails app to production and running into the routing issues. I've read this
I just found this project which provides a way of running Google App Engine
I'm following this tutorial: http://developer.android.com/training/basics/firstapp/running-app.html#Emulator In it there is a simple code for a
I'm using django with app-engine-patch and I'm having this wierd problem running manage.py dumpdata
Running this program is printing forked! 7 times. Can someone explain how forked! is

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.