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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:27:23+00:00 2026-06-14T12:27:23+00:00

I’m overriding the getItemViewType() method in my project to indicate which view to use

  • 0

I’m overriding the getItemViewType() method in my project to indicate which view to use for items in my list, R.layout.listview_item_product_complete or R.layout.listview_item_product_inprocess

I know this function must return a value between 0 and 1 less than the number of possible views, in my case 0 or 1.

How do I know which layout is 0 and which is 1? I presume the first layout I created will be 0 and the latter one 1, but I want to return a variable so that this value is flexible…

I.e.

@Override
public int getItemViewType(int position) {
    // Define a way to determine which layout to use
    if(//test for inprocess){ 
        return INPROCESS_TYPE_INDEX;
    } else { 
        return COMPLETE_TYPE_INDEX;
    }
}

What/where can I reference to define the values for COMPLETE_TYPE_INDEX and INPROCESS_TYPE_INDEX ?

  • 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-14T12:27:25+00:00Added an answer on June 14, 2026 at 12:27 pm

    I need to know how to define COMPLETE_TYPE_INDEX as 1 or 0. Seems like such a trivial thing!

    Honestly, it doesn’t matter whether COMPLETE_TYPE_INDEX is 0 and INPROCESS_TYPE_INDEX is 1, or vica versa. But you define them as class variables, in this case they can be static and final as well:

    public class MyAdapter ... {
        private static final int COMPLETE_TYPE_INDEX = 0;
        private static final int INPROCESS_TYPE_INDEX = 1;
        private static final int NUMBER_OF_LAYOUTS = 2;
    
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder = null;
            if (convertView == null) {
                if(getItemViewType(position) == COMPLETE_TYPE_INDEX)
                    convertView = mInflater.inflate(R.layout.listview_item_product_complete, null);
                else // must be INPROCESS_TYPE_INDEX
                    convertView = mInflater.inflate(R.layout.listview_item_product_inprocess, null);
    
                // etc, etc...
                // Depending on what is different in your layouts, 
                //   you may need update your ViewHolder and more of getView()
            }
    
            // Load data that changes on each row, might need to check index type here too
        }
        @Override
        public int getItemViewType(int position) {
            Order thisOrder = (Order) myOrders.getOrderList().get(position);
    
            if(thisOrder.getOrderStatus().equals("Complete")) return COMPLETE_TYPE_INDEX;
            else return INCOMPLETE_TYPE_INDEX;
        }
        @Override
        public int getViewTypeCount() {
            return NUMBER_OF_LAYOUTS;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from

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.