Android Community
Results 1 to 2 of 2

Thread: Programmatically set typeface and textsize of Spinner / ComboBox

  1. #1
    Join Date
    Sep 2009
    Posts
    3

    Default Programmatically set typeface and textsize of Spinner / ComboBox


    <html>
    <p>
    For other items settypeface and settextsize are available, but not forSpinner. I would like to have a mechanism that dynamically changesthe Spinner without using a fixed XML definition. I am trying to re-program the default android.R.layout.simple_spinner_item andandroid.R.layout.simple_spinner_dropdown_item containers. I have tried the following code without success. Where am I going wrong?
    <br><br>
    class ComboBox extends Spinner {
    <br> private int listid;
    <br> private ArrayList alist = new ArrayList();
    <br> private TextView ssi;
    <br> private CheckedTextView ssdi;
    <br> public ComboBox (Context context,int listid) {
    <br> super(context);
    <br> this.listid = listid;
    <br> ArrayAdapter ladapt = new ArrayAdapter(context,android.R.layout.simple_spinn er_item, alist);
    <br> ladapt.setDropDownViewResource(android.R.layout.si mple_spinner_dropdown_item);
    <br> setAdapter(ladapt);
    <br> ssi = (TextView)findViewById(android.R.layout.simple_spi nner_item);
    <br> ssdi = (CheckedTextView)findViewById(android.R.layout.sim ple_spinner_dropdown_item);
    <br> }
    <br> public int getId() {
    <br> return listid;
    <br> }
    <br> public void addItem(String txt) {
    <br> alist.add(txt);
    <br> }
    <br> public void setTypeface(Typeface tf) {
    <br> ssi.setTypeface(tf);
    <br> ssdi.setTypeface(tf);
    <br> }
    <br> public void setTextColor(int colour) {
    <br> ssi.setTextColor(colour);
    <br> ssdi.setTextColor(colour);
    <br> }
    <br> public void setTextSize(int sz) {
    <br> ssi.setTextSize(sz);
    <br> ssdi.setTextSize(sz);
    <br> }
    <br>}
    </p>
    </html>
    Last edited by mobiforms; 09-15-2009 at 01:38 AM.

  2. #2
    Join Date
    May 2009
    Location
    belleville, IL (st. louis)
    Posts
    745

    Default Re: Programmatically set typeface and textsize of Spinner / ComboBox


    might be a question to post over at XDA

Similar Threads

  1. Spinner help
    By boilermaker in forum Developers Guild
    Replies: 6
    Last Post: 06-22-2009, 02:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •