android spinner change font typeface

前端 未结 5 2073
被撕碎了的回忆
被撕碎了的回忆 2020-12-06 14:23

i\'m going to change text typeface to arialbold in my spinner how i\'m going to do so. Below is my code :-

ArrayAdapter genderAdap = Arra         


        
5条回答
  •  借酒劲吻你
    2020-12-06 15:22

    You would apply the font through your own custom SpinnerAdapter, in getView() and getDropDownView()

    public View getView(int position, View convertView, ViewGroup parent) {
    
        LayoutInflater inflater = getLayoutInflater();
                View row = inflater.inflate(yourRowlayout, parent,
                        false);
           TextView make = (TextView) row.findViewById(R.id.Make);
            Typeface myTypeFace = Typeface.createFromAsset(context.getAssets(),
                    "fonts/gilsanslight.otf");
            v.setTypeface(myTypeFace);
            v.setText(itemList.get(position));
            return row;
        }
    
    
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
    
            LayoutInflater inflater = getLayoutInflater();
                    View row = inflater.inflate(yourRowlayout, parent,
                            false);
               TextView make = (TextView) row.findViewById(R.id.Make);
                Typeface myTypeFace = Typeface.createFromAsset(context.getAssets(),
                        "fonts/gilsanslight.otf");
                v.setTypeface(myTypeFace);
                v.setText(itemList.get(position));
                return row;
            }
    

提交回复
热议问题