在android中增加ExpandbleListView的TextSize

时间:2016-02-05 12:15:17

标签: android

我想增加ExpandableListView xml的

 <ExpandableListView
    android:id="@+id/drawer_list"
    android:layout_width="240dp"
    android:childDivider="#00000000"
    android:background="#000000"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:choiceMode="singleChoice"
    android:divider="#9c9c9c"
    android:dividerHeight="1dp" >
</ExpandableListView>

1 个答案:

答案 0 :(得分:1)

在展开式列表视图适配器中,您将使用getGroupView()getChildView()方法对行进行充气,在那里您将访问TextView以使用所需的字符串填充它们。

只需致电.setTextSize(*float*)

具有视图持有者模式的getGroupView()示例:

public View getGroupView(final int i, boolean b, View view, ViewGroup viewGroup) {
    ViewHolder holder;

    if (view == null) {
        holder = new ViewHolder();
        view = mInflater.inflate(R.layout.your_row, viewGroup, false);
        TextView tvName = (TextView) view.findViewById(R.id.your_textview);
        holder.name = tvName;
        view.setTag(holder);
    } else {
        holder = (ViewHolder)view.getTag();
    }
holder.name.setText("your desired text value");
holder.name.setTextSize(22.0f);
}