Code example for TextView

Methods: setCompoundDrawablesWithIntrinsicBoundssetGravitysetPaddingsetText, setLayoutParams

0
			} catch (NameNotFoundException e) {
				return 0; 
			} 
        } 
        public TextView getGenericView() {
            TextView textView = new TextView(ActivityPickerActivity.this);
            textView.setLayoutParams(lpGroup);
            textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
            textView.setPadding(leftPadding, 0, 0, 0);
            return textView;
        } 
        public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                View convertView, ViewGroup parent) {
            TextView textView = getGenericView();
            ActivityInfo activity=getChild(groupPosition, childPosition);
            if(activity!=null){
	            String name=activity.name.replace(activity.packageName, "");
	        	textView.setText(activity.loadLabel(mPackageManager)+"("+name+")");
	        	textView.setLayoutParams(lpChild);
            } 
            return textView;
        } 
        public PackageInfo getGroup(int groupPosition) {
        	return groups.get(groupPosition);
        } 
        public int getGroupCount() { 
        	return groups.size();
        } 
        public long getGroupId(int groupPosition) {
            return groupPosition;
        } 
        public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
                ViewGroup parent) {
            TextView textView = getGenericView();
            PackageInfo info=getGroup(groupPosition);
            textView.setText(info.applicationInfo.loadLabel(mPackageManager));
            textView.setCompoundDrawablesWithIntrinsicBounds(Utilities.createIconThumbnail(info.applicationInfo.loadIcon(mPackageManager),ActivityPickerActivity.this), null, null, null);
            return textView;
        } 
        public boolean isChildSelectable(int groupPosition, int childPosition) {
            return true; 
        }