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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:48:03+00:00 2026-06-10T10:48:03+00:00

Here’s the code for my ItemAdapter which I use as an adapter for list

  • 0

Here’s the code for my ItemAdapter which I use as an adapter for list in this way.

list.setAdapter(new ItemAdapter(thisContext,imageUrl));

I’m trying to implement an onclick listener for the button that will add an item to a ListFragment. When I compile, it says “cannot resolve symbol getSupportFragmentManager”. See bold below. But I’m pretty sure I imported android.support.v4.app.FragmentActivity (see below).
I used the same getSupportFragmentManager in my main activity and it works. I don’t understand why it isn’t here. And if it isn’t, how should I obtain the HeadlinesFragment so that I can add to the list in that fragment?

Appreciate any help I can get here.

Pier.

package com.suite.android.menu;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
**import android.support.v4.app.FragmentActivity;**


public class ItemAdapter extends BaseAdapter {

private Context itemPageContext;
private String imagesUrl[];
private static final String TAG = "ItemAdapter" ;

public ItemAdapter(Context c, String[] imageUrl)
{
   super();
   itemPageContext = c;
   imagesUrl = imageUrl.clone();  // copy over


}

private LayoutInflater getLayoutInflater()
{
    return (LayoutInflater) itemPageContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

public View getView(final int position, View convertView, ViewGroup parent)
{
    // all this is for 1 item in the list

    View theView = convertView;
    final ViewHolder holder;
    if (convertView == null) {
        theView = getLayoutInflater().inflate(R.layout.item_list_image, null);
        holder = new ViewHolder();
        holder.text = (TextView) theView.findViewById(R.id.foodTitle);
        holder.image = (ImageView) theView.findViewById(R.id.foodImage);
        holder.button = (Button) theView.findViewById(R.id.addOrderButton);
        theView.setTag(holder);
    } else
        holder = (ViewHolder) theView.getTag();

    holder.text.setText("Item " + position);
    holder.image.setImageResource(R.drawable.ic_launcher);

    holder.button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            **HeadlinesFragment headFragment = (HeadlinesFragment) getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);**
            headFragment.AddItem("One");
            Log.d(TAG, "Added Item!");
        }
    });

    return theView;
}

private class ViewHolder {
    public TextView text;
    public ImageView image;
    public Button button;
}

@Override
public int getCount() {
    return imagesUrl.length;
}

@Override
public Object getItem(int position) {
    return position;
}

@Override
public long getItemId(int position) {
    return position;
}

}
  • 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-10T10:48:04+00:00Added an answer on June 10, 2026 at 10:48 am

    It’s been a while since I played around with fragments. but I believe you can only access getSupportedFragmentManager from an FragmentActivity class.

    try this

    public ItemAdapter(Context c,FragmentActivity activity, String[] imageUrl)
    {
       super();
       itemPageContext = c;
       this.activity = activity;
       imagesUrl = imageUrl.clone();  // copy over
    }
    

    then within the class extending FragmentActivity do this:

    list.setAdapter(new ItemAdapter(thisContext,thisActivity, imageUrl));
    

    then within the Adapter do this

    activity.getSupportedFragmentManager...
    

    Hope this helps

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

Sidebar

Related Questions

Here is the code in a function I'm trying to revise. This example works
Here a simple question : What do you think of code which use try
here is my code, SiteMember class @OneToMany(mappedBy = member,cascade=CascadeType.ALL) private List<MemberThread> memberThread = new
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is the css: #content ul { font-size: 12px; } I am trying this:
Here is the code I'm using inside my AsyncTask DefaultHttpClient httpClient = new DefaultHttpClient();
Here is what I am trying to achieve in PHP: I have this string:
Here is my code, which takes two version identifiers in the form 1, 5,
here is code: <script type=text/javascript> function doit(){ $('table td').each(function () { if ($(this).text().trim() !=
Here's my code, what I'm trying to do is have javascript check a form

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.