Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8335443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:40:44+00:00 2026-06-09T03:40:44+00:00

I am using ImageAdapter extends BaseAdapter to inflate a gridview . Gridview has two

  • 0

I am using ImageAdapter extends BaseAdapter to inflate a gridview. Gridview has two textviews. I want to set custom font for one of them. Using Typeface font = Typeface.createFromAsset(getAssets(), "BABYCAKE.TTF"); in ImageAdapter gives error The method getAssets() is undefined for the type ImageAdapter.

ImageAdapter is defined as

package com.amit.wozzle;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
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.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.view.LayoutInflater;

public class ImageAdapter extends BaseAdapter
{  
private ArrayList<String> listCountry;  
private ArrayList<String> scorestage;  
private Activity activity;  
Typeface font;

public ImageAdapter(Activity activity,ArrayList<String> listCountry, ArrayList<String> scorestage) {  
    super();  
    this.listCountry = listCountry;  
    this.scorestage = scorestage;  
    this.activity = activity;  
    font = Typeface.createFromAsset(activity.getAssets(), "BABYCAKE.TTF");
}  

@Override  
public int getCount() {  
    // TODO Auto-generated method stub  
    return listCountry.size();  
}  

@Override  
public String getItem(int position) {  
    // TODO Auto-generated method stub  
    return listCountry.get(position);  
}  

@Override  
public long getItemId(int position) {  
    // TODO Auto-generated method stub  
    return 0;  
}  

public static class ViewHolder  
{  
    public ImageView imgViewFlag;  
    public TextView  txtViewTitle; 
    public TextView  txtViewTitle2; 
}  

@Override  
public View getView(int position, View convertView, ViewGroup parent) {  
    // TODO Auto-generated method stub  
    ViewHolder view;  
    LayoutInflater inflator = activity.getLayoutInflater();  

    if(convertView==null)  
    {  
        view = new ViewHolder();  
        convertView = inflator.inflate(R.layout.grid_item, null);  
        view.txtViewTitle = (TextView) convertView.findViewById(R.id.textView1);  
        view.txtViewTitle2.setTypeface(font);
        view.txtViewTitle2 = (TextView) convertView.findViewById(R.id.textView2);  

        // view.imgViewFlag = (ImageView) convertView.findViewById(R.id.imageView1);  
        convertView.setTag(view);  
    }  
    else  
    {  
        view = (ViewHolder) convertView.getTag();  
    }  
    // view.txtViewTitle2.setBackgroundColor(Color.BLUE);
    view.txtViewTitle2.setText(listCountry.get(position)); 
    view.txtViewTitle.setText(scorestage.get(position)); 
    // view.imgViewFlag.setImageResource(scorestage.get(position));  

    return convertView;  
}  
}

Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:40:47+00:00Added an answer on June 9, 2026 at 3:40 am

    try

    Typeface font = Typeface.createFromAsset(activity.getAssets(), "BABYCAKE.TTF");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using grid view with ImageAdapter to display images. I have two set
I'm using a Gallery (android.widget.gallery) with an ImageAdapter which extends BaseAdapter. I need to
public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext
I am downloading images using a imageAdapter extending a base class. Im storing them
So basically the screen has a GridView with 9 images on it. When one
I want to display different images using gridview in android? Xml file: <?xml version=1.0
i'm developing an app for android and want using GridView build a menu with
Using a populated Table Type as the source for a TSQL-Merge. I want to
Using android 2.3.3, I have a background Service which has a socket connection. There's
Using WPF/PRISM I want to log my messages through ILoggerFacade to my GUI (A

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.