File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes Programmatically set typeface and textsize of Spinner / ComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Programmatically set typeface and textsize of Spinner / ComboBox" Watch "Programmatically set typeface and textsize of Spinner / ComboBox" New topic
Author

Programmatically set typeface and textsize of Spinner / ComboBox

Tim Donald
Greenhorn

Joined: Sep 15, 2009
Posts: 1
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);
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Programmatically set typeface and textsize of Spinner / ComboBox
 
Similar Threads
Layout_height setting error
trying to add items dynamically to spinner with alertdialog
How to add a textview dynamically in a table row in table layout
styling items of a ListView
Tring to do a spinner and i am getting errors