Custom Spinner Adapter

后端 未结 5 1165
借酒劲吻你
借酒劲吻你 2020-11-30 07:19

I wanted to apply a custom font to my spinner. The only way i found out is that to create a custom adapter. Here is my code

    private class CustomAdapter e         


        
5条回答
  •  时光说笑
    2020-11-30 07:42

    Try

    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;
            }
    

提交回复
热议问题