I am new to programming in android and I am struggling with the following problem. I am using a Custom ListView to display a Store name and their Logo. I want to change the standard textview font for a custom font.
The method I use for a normal textview is not working. Can you please Help me?
The following code is my ListView Adapter.
package com.mallspecials.shoppingmallspecialsau;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class ShowTheStoreAdapter extends BaseAdapter {
// Declare Variables
Context context;
String[] thestore;
int[] logo;
LayoutInflater inflater;
public ShowTheStoreAdapter(Context context, String[] thestore, int[] logo) {
this.context = context;
this.thestore = thestore;
this.logo = logo;
}
private AssetManager getAssets() {
// TODO Auto-generated method stub
return null;
}
@Override
public int getCount() {
return thestore.length;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
//Set Snell Roundhand Font for the StoreName
Typeface font = Typeface.createFromAsset(getAssets(), "Snell Roundhand Bold Script.ttf");
// Declare Variables
TextView StoreName;
ImageView imglogo;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.listview_stores, parent, false);
//Set the StoreName Text
StoreName = (TextView) itemView.findViewById(R.id.thestore);
StoreName.setTextColor(Color.RED);
StoreName.setShadowLayer(3, -2, -5,(Color.YELLOW));
StoreName.setTypeface(font);
StoreName.setText(thestore[position]);
// Locate the ImageView in listview_stores.xml
imglogo = (ImageView) itemView.findViewById(R.id.storelogo);
// Capture position and set to the ImageView
imglogo.setImageResource(logo[position]);
return itemView;
}
}
Below is the code for my adapter View implementation.
list = (ListView) findViewById(R.id.listview);
adapter = new ShowTheStoreAdapter(this, thestore, storelogo);
list.setAdapter(adapter);