I want to show many icons which I will be getting from the fonticon.ttf which works fine.
The onCreate function is like below:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Typeface font = Typeface.createFromAsset(getAssets(), "fontawesome-webfont.ttf");
Button button = (Button)findViewById( R.id.like2 );
button.setTypeface(font);
}
But as you can see this is restricted to a single button with id as like2
. But I want to have something like a html class or something which I can call so that when ever I use it, it automatically renders the icon for me.
My simple design goes like below:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/login_button1"
android:layout_alignParentLeft="true"
android:background="#7000"
android:orientation="vertical"
android:paddingTop="5dp" >
<Button
android:id="@+id/like1"
android:layout_width="10dp"
android:layout_height="10dp"
android:text="@string/icon_heart"
android:textColor="#CCC"
android:layout_alignParentRight="true"
android:background="#00000000"
android:layout_marginRight="5dp"
android:textSize="50sp" />
</RelativeLayout>
I will be using same icons many times and it seems impossible to include all of them in one onCreate as they will be loaded once and http get request is completed.
Could someone please assist me?