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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:51:52+00:00 2026-06-11T11:51:52+00:00

I want to set a custom listview adapter in my Preferences class with an

  • 0

I want to set a custom listview adapter in my Preferences class with an adapter located in my main class. When I try:

MyActivity.listView.setAdapter(new MyActivity.UserItemAdapter2(Prefs.this, R.layout.listitem, MyActivity.tweets));

I get an error stating “No enclosing instance of type MyActivity is accessible.” I can’t make my adapter class static because it calls getSystemService, which is a non-static method. How do resolve this? Any help is greatly appreciated.
Here is my adapter class:

public class UserItemAdapter2 extends ArrayAdapter<Tweet> {
            private ArrayList<Tweet> tweets;

            public UserItemAdapter2(Context context, int textViewResourceId, ArrayList<Tweet> tweets) {
                super(context, textViewResourceId, tweets);
                this.tweets = tweets;
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View v = convertView;
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.listitem, null);
                }

                Tweet tweet = tweets.get(position);
                if (tweet != null) {
                    TextView username = (TextView) v.findViewById(R.id.username);
                    TextView message = (TextView) v.findViewById(R.id.message);
                    ImageView image = (ImageView) v.findViewById(R.id.avatar);

                    if (username != null) {
                        username.setText(tweet.username);
                    }

                    if(message != null) {
                        message.setText(tweet.message);
                    }

                    if(image != null) {
                        //image.setImageBitmap(getBitmap(tweet.image_url));
                        tango.DisplayImage(tweet.image_url, image);
                    }
                }
                return v;
            }
        }  
  • 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-11T11:51:53+00:00Added an answer on June 11, 2026 at 11:51 am

    You could just pull that Adapter out into its own file so you can use it from anywhere.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a custom set that will automatically convert objects into a
I created a custom EditorPart, and I want to set the Zone and ZoneIndex
i want to build a custom event with jQuery that is not set to
i want maven to download custom jar files from an ftp how to set
I have a large data set and I want to write a custom merge
i want set class for repeater when doPostBack for those dataID i wan but
I want to set custom Post-Login Destinations based on user ROLES in my application.
I want to set a custom exception message. However, I'm unsure of how to
I have a listview with custom array adapter, the view allows the user to
I currently have a ListView with a custom adapter that gets information describing the

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.