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 6128523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:38:12+00:00 2026-05-23T16:38:12+00:00

So I’m just trying to currently inflate a view in my getView function and

  • 0

So I’m just trying to currently inflate a view in my getView function and getContext() for some reason is saying it’s undefined..

package com.MTSUAndroid;

import com.MTSUAndroid.Alarm_Settings.EfficientAdapter1.ViewHolder;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.ImageView;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap;

public class Alarm_Settings extends ListActivity {
    public static class EfficientAdapter1 extends BaseAdapter{
        private LayoutInflater mInflater;

        public EfficientAdapter1(Context context){
            mInflater = LayoutInflater.from(context);
        }
        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return 0;
        }

        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return position;
        }

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

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
            int viewType = this.getItemViewType(position);

            switch (viewType)
            {
            case 1:
                holder = new ViewHolder();

                View v = convertView;
                if (v == null)
                {
                    LayoutInflater vi = null;
                    //LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.alerts,parent,false);

                    holder.text1 = (TextView)v.findViewById(R.id.menu_Cancel);
                    v.setTag(holder);
                }
                else {
                    holder = (ViewHolder)v.getTag();
                }
                return v;
            case 2:
                ViewHolder holder1 = new ViewHolder();

                View v1 = convertView;
                if (v1 == null)
                {
                    LayoutInflater vi = null;
                    //LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v1 = vi.inflate(R.layout.about, parent, false);

                    holder1.text1 = (TextView)v1.findViewById(R.id.menu_Cancel);
                    v1.setTag(holder1);
                }
                else {
                    holder1 = (ViewHolder)v1.getTag();
                }

                return v1;
            }
            return null;
        }

        static class ViewHolder{
            TextView text1;
        }

    }
    public void onCreate(Bundle SavedInstanceState)
    {
        super.onCreate(SavedInstanceState);
        setListAdapter(new EfficientAdapter1(this));
        ListView listview = getListView();
        listview.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                Intent intent = new Intent(Alarm_Settings.this, Alerts.class);
                startActivity(intent);
            }
        });
    }
}

This is the piece of code I’m having problems with. LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); getContext() isn’t defined for the class and I don’t understand why 🙁

  • 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-05-23T16:38:12+00:00Added an answer on May 23, 2026 at 4:38 pm

    You call it in the class EfficientAdapter1 which does not extend activity and has no such method.

    Add a Context field to the internal class and call getSystemService on it:

    /* snip */
    public static class EfficientAdapter1 extends BaseAdapter{
        private LayoutInflater mInflater;
        private Context ctx;
        public EfficientAdapter1(Context context){
            mInflater = LayoutInflater.from(context);
            ctx = context;
        }
    /* snip */
         LayoutInflater vi = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    /* snip */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.