• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Programmatically set typeface and textsize of Spinner / ComboBox

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For other items settypeface and settextsize are available, but not for
Spinner. I would like to have a mechanism that dynamically changes
the Spinner without using a fixed XML definition. I am trying to re-
program the default android.R.layout.simple_spinner_item and
android.R.layout.simple_spinner_dropdown_item containers. I have
tried the following code without success. Where am I going wrong?

class ComboBox extends Spinner {
private int listid;
private ArrayList<String> alist = new ArrayList<String>();
private TextView ssi;
private CheckedTextView ssdi;
public ComboBox (Context context,int listid) {
super(context);
this.listid = listid;
ArrayAdapter<String> ladapt = new ArrayAdapter<String>(context,
android.R.layout.simple_spinner_item, alist);
ladapt.setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
setAdapter(ladapt);
ssi = (TextView)findViewById
(android.R.layout.simple_spinner_item);
ssdi = (CheckedTextView)findViewById
(android.R.layout.simple_spinner_dropdown_item);
}
public int getId() {
return listid;
}
public void addItem(String txt) {
alist.add(txt);
}
public void setTypeface(Typeface tf) {
ssi.setTypeface(tf);
ssdi.setTypeface(tf);
}
public void setTextColor(int colour) {
ssi.setTextColor(colour);
ssdi.setTextColor(colour);
}
public void setTextSize(int sz) {
ssi.setTextSize(sz);
ssdi.setTextSize(sz);
}
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic