There are several ways to do this, my favorite two are to set it in an XML layout. This will work if each "Button2" needs the same custom font, and if the Typeface you want is already part of the system.
<TextView android:id="@+id/button2" android:layout_height="wrap_content" android:layout_width="wrap_content" android:typeface="sans" />
The second way to do this is to customize the ListAdapter using the ViewBinder . As Pinassi wrote, this can be done from getView() , however this has the disadvantage that it cannot easily see the data and mixes the general user interface code with the user interface user code. Both SimpleAdapter and SimpleCursorAdapter have an inner class called ViewBinder with the setViewValue method. Each signature is different in that it manages the underlying data.
Just override setViewValue just for the setting you want to manually configure. For example, R.id.button1 is a simple text binding, just the method returns false, and the API will handle it for you, but since we are setting R.id.button2 , we will return true.
switch(v.getId){ case R.id.button2: TextView button2 = (TextView) v; button2.setTypeface(customTypeFace); // bind text here or return false to allow the API to do this for you. break; // other customization }
customTypeFace comes from a Typeface system or a project resource folder . Android uses TrueType Fonts.
Dan s source share