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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:41:23+00:00 2026-06-01T22:41:23+00:00

I have listview app exploring cities each row point to diffrent city , in

  • 0

I have listview app exploring cities each row point to diffrent city , in each city activity include button when clicked open new activity which is infinite gallery contains pics of that city , i add infinite gallery to first city and work fine , when i want to add it to the second city , it gave me red mark error in the class as follow :

1- The type InfiniteGalleryAdapter is already defined.

2-The type InfiniteGallery is already defined.

I tried to change class name with the same result, I delete R.java and eclipse rebuild it with same result. Also I unchecked the java builder from project properties and get same red mark error.

Please any help and advice will be appreciated

thanks

My Code:

public class SecondCity extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
        // Set the layout to use
        setContentView(R.layout.main);
        if (customTitleSupported) {
            getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title); 
            TextView tv = (TextView) findViewById(R.id.tv); 
            Typeface face=Typeface.createFromAsset(getAssets(),"BFantezy.ttf");     
            tv.setTypeface(face);
            tv.setText("MY PICTURES"); 
        }

        InfiniteGallery galleryOne = (InfiniteGallery) findViewById(R.id.galleryOne);
        galleryOne.setAdapter(new InfiniteGalleryAdapter(this));     
    }
}


class InfiniteGalleryAdapter extends BaseAdapter { 
    **//red mark here (InfiniteGalleryAdapter)** 
    private Context mContext;

    public InfiniteGalleryAdapter(Context c, int[] imageIds) { 
        this.mContext = c;
    } 

    public int getCount() { 
        return Integer.MAX_VALUE;
    } 

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

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

    private LayoutInflater inflater=null;
    public InfiniteGalleryAdapter(Context a) { 
        this.mContext = a; 
        inflater = (LayoutInflater)mContext.getSystemService ( Context.LAYOUT_INFLATER_SERVICE)
    } 

    public class ViewHolder{ 
        public TextView text; 
        public ImageView image;
    } 

    private int[] images = {
        R.drawable.pic_1, R.drawable.pic_2, 
        R.drawable.pic_3, R.drawable.pic_4, 
        R.drawable.pic_5
    }; 

    private String[] name = {
        "This is first picture (1) " ,
        "This is second picture (2)",
        "This is third picture (3)", 
        "This is fourth picture (4)",
        " This is fifth picture (5)"
    }; 

    public View getView(int position, View convertView, ViewGroup parent) { 
        ImageView i = getImageView(); 

        int itemPos = (position % images.length); 

        try {
            i.setImageResource(images[itemPos]); ((BitmapDrawable) i.getDrawable()).
            setAntiAlias  (true);
        } 

        catch (OutOfMemoryError e) {
            Log.e("InfiniteGalleryAdapter", "Out of memory creating imageview. Using empty view.", e);
        } 

        View vi=convertView; 
        ViewHolder holder; 
        if(convertView==null){ 
            vi = inflater.inflate(R.layout.gallery_items, null); 
            holder=new ViewHolder(); holder.text=(TextView)vi.findViewById(R.id.textView1); 
            holder.image=(ImageView)vi.findViewById(R.id.image); 
            vi.setTag(holder);
        } else {
            holder=(ViewHolder)vi.getTag();
        } 
        holder.text.setText(name[itemPos]); 

        final int stub_id=images[itemPos]; 
        holder.image.setImageResource(stub_id); 

        return vi;
    } 

    private ImageView getImageView() { 

        ImageView i = new ImageView(mContext); 

        return i;
    } 
}

class InfiniteGallery extends Gallery {
    **//red mark here (InfiniteGallery)** 

    public InfiniteGallery(Context context) {
        super(context);
        init();
    } 

    public InfiniteGallery(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public InfiniteGallery(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    private void init(){
        // These are just to make it look pretty
        setSpacing(25);
        setHorizontalFadingEdgeEnabled(false);
    } 

    public void setResourceImages(int[] name){
        setAdapter(new InfiniteGalleryAdapter(getContext(), name));
        setSelection((getCount() / 2));
    }
}
  • 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-01T22:41:24+00:00Added an answer on June 1, 2026 at 10:41 pm

    You are getting those red marks as these class are already defined in one of your previous class. Java won’t let have duplicate names. Also it seems you are trying to define same classes for every Actvitiy which is redundant.

    Just remove the two classes completely from your SecondActivity java file as they are already defined in a previous activity. I would suggest you to make a separate package where the Adapter and InfiniteGallery are defined and kept to be reused .

    public class SecondCity extends Activity {
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            Boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
            // Set the layout to use
            setContentView(R.layout.main);
            if (customTitleSupported) {
                getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title); 
                TextView tv = (TextView) findViewById(R.id.tv); 
                Typeface face=Typeface.createFromAsset(getAssets(),"BFantezy.ttf");     
                tv.setTypeface(face);
                tv.setText("MY PICTURES"); 
            }
    
            InfiniteGallery galleryOne = (InfiniteGallery) findViewById(R.id.galleryOne);
            galleryOne.setAdapter(new InfiniteGalleryAdapter(this));     
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app using a ListView as a main screen. Each row displays
In my Android App I have a listview containing 30 rows, and each row
Hallo all, I have a ListView which contains a Button in each line. The
i have listview the fisrt time i when i click to row it open
I have a ListView with a pretty standard view for each row - an
I have an app with a large ListView which is terribly slow so I'm
I have a WPF App that implements a ListView. I would like to show
If I have two activities in my app, one with listview and the other
I have a listview and a button to remove items from that listview. The
I have a ListView in my app, and every week, I am adding 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.