문제

I have a ListView. When I try to make it's row's textview bold - it falls. I try:

ListView list = (ListView) findViewById(R.id.my_list);

list.setAdapter(someListAdapter);

((TextView) list.getChildAt(0).findViewById(R.id.first_name)).setTypeface(null, Typeface.BOLD);

I need to do this with only one (headers) row's textviews.

도움이 되었습니까?

해결책

I need to do this with only one (headers) row's textviews.

Try calling this before calling addHeaderView(view):

((TextView) view.findViewById(R.id.first_name)).setTypeface(null, Typeface.BOLD);

If you not using addHeaderView(), extend your adapter and add a snippet of code like this to getView():

if(position == 0)
    ((TextView) convertView.findViewById(R.id.first_name)).setTypeface(null, Typeface.BOLD);
else
    ((TextView) convertView.findViewById(R.id.first_name)).setTypeface(null, Typeface.NORMAL);

(I recommend using a ViewHolder, rather than calling findViewById() repeatedly. This is just for a quick example.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top