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

  • Home
  • SEARCH
  • 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 6056003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:19:40+00:00 2026-05-23T08:19:40+00:00

I have create a sample which has differet layout for few rows in ListView

  • 0

I have create a sample which has differet layout for few rows in ListView based on the this link. Here is the layout

Here is my layout

As i want only first row to have a different layout , whenever the position is zero i am applying layout one ( Name & Phone) and for rest i am applying layout two (Address).

the problem i am facing is when i fire notifyDataSetChanged on adapter , only my Address get changed but Name & Phone row i.e. first row doesn’t update. I am firing notifyDataSetChanged when the submenu item is selected.

Here is the code.

public static final int TYPE_ADDRESS = 1;
public static final int TYPE_NAME = 0;
public static final int TYPE_MAX_COUNT =2;

@Override
public int getItemViewType(int position) {
    if(position == 0)
        return TYPE_NAME;
    else
        return TYPE_ADDRESS;
}
@Override
public int getViewTypeCount() {
    return TYPE_MAX_COUNT;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {


    ViewHolder holder=null;
    int type = getItemViewType(position);
    System.out.println("getView " + position + " " + convertView + " type = " + type);




 if (convertView == null) {
     holder = new ViewHolder();


    switch (type) {
        case TYPE_ADDRESS:
                    convertView = mInflater.inflate(R.layout.layout_address, null);
                    holder.address = (TextView) convertView.findViewById(R.id.address_id);                  
                    holder.address.setText(data.getAddress(position));


                    break;

        case TYPE_NAME:                        
                    convertView = mInflater.inflate(R.layout.layout_name, null);                    
                    holder.name = (TextView)convertView.findViewById(R.id.name_id);
                    holder.phone = (TextView)convertView.findViewById(R.id.phone_id);



                    holder.name.setText(data.getName(position));
                    holder.phone.setText(data.getPhone(position));




                    break;
    }

        convertView.setTag(holder);          

   }else {

    holder = (ViewHolder) convertView.getTag();
   }    



    return convertView;
}



static class ViewHolder {
        TextView address;
        TextView name;
        TextView phone;

    }
  • 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-23T08:19:41+00:00Added an answer on May 23, 2026 at 8:19 am

    AFAIK, you need to manage views (like setting text) outside if (convertView == null){}else{} block, since you need it to be invoked in any case, not only on view creating. Could it be the issue?

    if (convertView == null) {
         holder = new ViewHolder();
    
    
        switch (type) {
            case TYPE_ADDRESS:
                        convertView = mInflater.inflate(R.layout.layout_address, null);
                        holder.address = (TextView) convertView.findViewById(R.id.address_id);                                     
    
                        break;
    
            case TYPE_NAME:                        
                        convertView = mInflater.inflate(R.layout.layout_name, null);                    
                        holder.name = (TextView)convertView.findViewById(R.id.name_id);
                        holder.phone = (TextView)convertView.findViewById(R.id.phone_id);
    
                        break;
        }
    
            convertView.setTag(holder);          
    
       }else {
    
        holder = (ViewHolder) convertView.getTag();
       }    
    
       switch (type) {
            case TYPE_ADDRESS:
                  holder.address.setText(data.getAddress(position));
                  break;
            case TYPE_NAME:                        
                  holder.name.setText(data.getName(position));
                  holder.phone.setText(data.getPhone(position)); 
                  break;       
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to read a text file which has text as follows(sample) abc ip-32-56-198-18.com
This is what I currently have: CREATE OR REPLACE TRIGGER MYTRIGGER AFTER INSERT ON
I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
I want to create a program which calculates how long it will take to
I have a dropdownlist for which I am loading data from excel. Excel has
Is it possible to create a WCF REST 4.0 service which has two endpoints
I have created a simple wcf service which used the WCF Service Library template.
I have created a simple Asp.Net custom control which automatically combines all the correct
I have a requirement to create a simple database in Access to collect some
I have a simple PowerShell script that uses WMI to create a web site

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.