Code example for ListView

Methods: getItemAtPosition

0
        setListAdapter(getSampleAdapter()); 
    } 
 
    @Override 
    protected void onListItemClick(ListView l, View v, int position, long id) {
        ActivityInfo info = (ActivityInfo) l.getItemAtPosition(position);
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(this, info.name));
        startActivity(intent);
    } 
 
    private ListAdapter getSampleAdapter() {
        ArrayList<ActivityInfo> items = new ArrayList<ActivityInfo>();
        final String thisClazzName = getClass().getName();
 
        try { 
            PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(),
                    PackageManager.GET_ACTIVITIES);
            ActivityInfo[] aInfos = pInfo.activities;
 
            for (ActivityInfo aInfo : aInfos) {