we need changed spinner fonts it is possible your font manager
Activity
GcsSloop commentedon May 8, 2016
It is possible
Step0: add this library to your project.
Step1: add spinner in your layout file
Step2: build some data in values/arrays.xml
Step3: find spinner and data in Activity
Step4: init the manager
at first you should have a font file in assets,
then use initFormAssets to init the FontsManager.
Step5: build an Adapter(ArrayAdapter or BaseAdapter)
you should Override the method of getView and getDropDownView
Step6: setAdapter
Step7: setOnItemSelectedListener
that's all, the important is Step4 and Step5.
The full code of Activity
ananthramasamy23 commentedon May 9, 2016
Hi frd,
Thanks for sharing knowledge I got output lot of thanks frd...
Thanks And Regards
Anandharaj R
Android developer
Email:anand@sqindia.net / ananthramasamy@hotmail.com
---- On Sun, 08 May 2016 15:44:20 +0530 sloop <notifications@github.com>wrote ----
It is possible
may be it is a little complicated
Step0: add this library to your project.
Step1: add spinner in your layout file
<Spinner android:layout_margin="100dp" android:id="@+id/spinner" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
Step2: build some data in values/arrays.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="languages"> <item>Java</item> <item>Android</item> <item>Python</item> <item>PHP</item> </string-array> </resources>
Step3: find spinner and data in Activity
Spinner spinner = (Spinner) findViewById(R.id.spinner); String[] mItems = getResources().getStringArray(R.array.languages);
Step4: init the manager
at first you should have a font file in assets,
then use initFormAssets to init the FontsManager.
FontsManager.initFormAssets(this,"AeroliteCPtwo.otf");
Step5: build an Adapter(ArrayAdapter or BaseAdapter)
you should Override the method of getView and getDropDownView
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mItems) { @OverRide public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); FontsManager.changeFonts(v); // <------------- Here, change typeface of items return v; } @OverRide public View getDropDownView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); FontsManager.changeFonts(v); // <------------- Here, change typeface of items return v; } };
Step6: setAdapter
spinner.setAdapter(adapter);
Step7: setOnItemSelectedListener
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @OverRide public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { } @OverRide public void onNothingSelected(AdapterView<?> parent) { } });
that's all, the important is Step4 and Step5.
The full code of Activity
public class MainActivity extends Activity { @OverRide protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FontsManager.initFormAssets(this,"AeroliteCPtwo.otf"); Spinner spinner = (Spinner) findViewById(R.id.spinner); String[] mItems = getResources().getStringArray(R.array.languages); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mItems) { @OverRide public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); FontsManager.changeFonts(v); // <------------- Here. change the typeface of items return v; } @OverRide public View getDropDownView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); FontsManager.changeFonts(v); // <------------- Here. change the typeface of items return v; } }; spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @OverRide public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { } @OverRide public void onNothingSelected(AdapterView<?> parent) { } }); } }
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub