last day (14 days later) » 

8:13 AM
0
A: Custom font for spinner in android

Tulsiram RathodGet font type which you want .ttf file and place in assets/fonts/xyz.ttf Use below code for set font: Typeface font = Typeface.createFromAsset(getContext().getAssets(), "fonts/xyz.ttf"); txtView.setTypeface(font); add where you have your league_headr_title i.e in your custom adapter class. If...

 
Hi Tulasiram, thanks for your reply. What is R.layout.cutom_adapter which you have written in the code
 
this is your custom layout file for adapter. which contains <TextView android:id="@+id/league_headr_title" android:layout_width="fill_parent" android:layout_height="30dp" android:textColor="@color/black" android:textSize="15dp" android:text="league" android:gravity="left|center_vertical" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" />
 
Yes i have given that one only. But I changed the constructor to below public CityAdapter(Context context, int textViewResourceId, ArrayList<City> list) { //super(context, R.layout.spinnerdroapdown_custom_item, list); super(context,textViewResourceId, list); this.mContext = context; this.cities = list; } In my activity class i am calling like below. CityAdapter objectLocationsDataAdapter = new CityAdapter(getBaseContext(), R.layout.spinnerdroapdown_custom_item, cities); Spinner_locations.setAdapter(objectLocationsDataAdapter);
But at runtime i am getting exception "Arrayadapter requires resource id to be text view"
 
call like CityAdapter cityAdapter = new CityAdapter(getBaseContext(), listCity); Spinner_locations.setAdapter(cityAdapter);
 
If I try to keep the constructor like below public CityAdapter(Context context, ArrayList<City> list) { //super(context, R.layout.spinnerdroapdown_custom_item, list); super(context,list); then i am getting "change the type of list to int"
 
8:13 AM
dont change constuctor cause i already added adapter_layout. so thats why your list treated for layout which is not int.
 
Now I keep it as it is, the font is applied to spinner, but while clicking on the spinner, then i am getting the exception and application is closing forcefully. please check the screen shot in the above, just now i have added to the question.
Hi Tulasiram, are you there?
have you seen my error log?
 
8:31 AM
give me some time
 
8:50 AM
ok
 
9:26 AM
yes whats the problem
 
9:38 AM
when the activity is coming then for the selected item it is applying the font, But when I click on the spinner then it is throwing the exception
I have kept the screenshot of log in the question
could you please check it
 
9:52 AM
ok
give me your code
all files that needed
 
I have provided the code which i am using in the question
 
ok i will do
 
10:16 AM
check updated answer i just created
 
Hi I have overrideen the public View getDropDownView(int position, View convertView, android.view.ViewGroup parent) {} method
and now onwards i am not getting the exception
anyway thanks for your help
 

last day (14 days later) »