public class CustomExpandableListAdapter extends BaseExpandableListAdapter 
{     
    AbsListView.LayoutParams lp = new 
AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 
ViewGroup.LayoutParams.WRAP_CONTENT);    
    SpannableString spanString=null;    
    
    String[] groups;
    String[][] children;
    Context context;

    public CustomExpandableListAdapter(Context context, String[] groups, 
String[][] children) {
        super();
        this.groups = groups;
        this.children = children;
        this.context = context;
    }

    public Object getChild(int groupPosition, int childPosition) {
        return children[groupPosition][childPosition];
    }

    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    public int getChildrenCount(int groupPosition) {
        return children[groupPosition].length;
    }

    public TextView getGenericView() {
        TextView textView = new TextView(context);        
        textView.setLayoutParams(lp);             
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
        return textView;
    }
     
    public View getChildView(int groupPosition, int childPosition, boolean 
isLastChild, View convertView, ViewGroup parent) {
        TextView auxTextView = getGenericView();
        auxTextView.setText(Html.fromHtml(getChild(groupPosition, 
childPosition).toString()));
        auxTextView.setTextSize(Util.CHILD_TEXT_SIZE);           
        auxTextView.setPadding(20, 10, 20, 10);
        auxTextView.setTextColor(Util.FONT_COLOR_CHILD);
        return auxTextView;
    }        
    
    public View getGroupView(int groupPosition, boolean isExpanded, View 
convertView, ViewGroup parent) {
        TextView auxTextView = getGenericView();
        auxTextView.setTextSize(24);
        auxTextView.setPadding(10, 10, 10, 10);
        auxTextView.setTextColor(Util.FONT_COLOR_PARENT);
        
        spanString = new 
SpannableString(getGroup(groupPosition).toString());
        spanString.setSpan(new StyleSpan(Typeface.BOLD), 0, 
spanString.length(), 0);
        spanString.setSpan(new StyleSpan(Typeface.ITALIC), 0, 
spanString.length(), 0);
        auxTextView.setText(spanString);
        
        return auxTextView;
    }

    public Object getGroup(int groupPosition) {
        return groups[groupPosition];
    }

    public int getGroupCount() {
        return groups.length;
    }

    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return false;
    }

    public boolean hasStableIds() {
        return true;
    }    
}

El lunes, 4 de febrero de 2013 20:11:57 UTC+1, skink escribió:
>
>
>
> saex wrote: 
> > OK, Sorry guys, now i understand you 
> > 
> > I tryed using your answers to get the solution but it doesn't works by 
> now, 
> > i don't know what i'm doing wrong 
> > 
> > This is the code now (this code is on the handler that is being called 
> each 
> > second from a thread). el is the expandableListView and mAdapter is the 
> > adapter for the expandableListView 
> > 
> > TextView tv = (TextView) mAdapter.getChildView(1, 0, true, 
> > (TextView)el.getChildAt(1),  el); 
> >  tv.setText("My New Text"); 
> > 
> > The child is not changing, so something is going wrong... :/ 
> > 
> > 
> > 
>
> what adapter are you extending? 
>
> pskink 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to