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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:59:15+00:00 2026-06-14T16:59:15+00:00

I have a custom adapter and its getView is not being called. Thats my

  • 0

I have a custom adapter and its “getView” is not being called.
Thats my main activity:

public class MainActivity extends Activity {
RelativeLayout mainRelativeLayout;
ListView listViewOne;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    String[] values1 = new String[] { " ", "Android", "iPhone", "WindowsMobile" };
    ListArr listArr = new ListArr(this, 3);
    listArr.AddListToListArr(values1);
}

}

thats my adapter:

public class MyAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[] values;
private TextView textView;
private ImageView icon;

public MyAdapter(Context context, String[] values) {
    super(context, R.layout.first_row, values);
    this.context = context;
    this.values = values;
}

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

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rowView;

    rowView = inflater.inflate(R.layout.first_row, parent, false);
    textView = (TextView) rowView.findViewById(R.id.row_text_view);

    icon.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_launcher));
    textView.setText(values[position]);
    return rowView;
}}

and thats the Class that is creating the list:

public class ListArr {
int indexOfEmptyCellInArr;
ListView[] listArr;
Context context;
LinearLayout mainRelativeLayout;

public ListArr(Context context, int numOFLists) {
    this.listArr = new ListView[numOFLists];
    this.indexOfEmptyCellInArr = 0;
    this.context = context;
    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.activity_main, null);
    this.mainRelativeLayout = (LinearLayout) v.findViewById(R.id.main_relative_layout);
}

public void AddListToListArr(String[] stringsOfNewList) {
    ArrayAdapter<String> arrayAdapter = new MyAdapter(context, stringsOfNewList);
    ListView listview = new ListView(context);
    listview.setAdapter(arrayAdapter);
    listArr[indexOfEmptyCellInArr] = listview;
    mainRelativeLayout.addView(listArr[indexOfEmptyCellInArr]);

    indexOfEmptyCellInArr++;
}

public void RemoveLastList(){
    int indexOfListToRemove = indexOfEmptyCellInArr - 1;
    listArr[indexOfListToRemove] = null;
    indexOfEmptyCellInArr--;
}

Why is it that the getView is not being called?
Thanks!

  • 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-14T16:59:16+00:00Added an answer on June 14, 2026 at 4:59 pm

    You havent add the mainRelativeLayout to the contentview, of the activity. you should use, findViewById(), instead, applying an extra LayoutInflater. Using LayoutInflater.inflate() method will result an extra inflating of layout, and it will create a new view, who has not been added to the list view yet. so Change your code to following:

    public class MainActivity extends Activity {
    RelativeLayout mainRelativeLayout;
    ListView listViewOne;
    
    @Override
    
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            String[] values1 = new String[] { " ", "Android", "iPhone", "WindowsMobile" };
            ListArr listArr = new ListArr(this, this, 3);
            listArr.AddListToListArr(values1);
        }
        }
    

    and ListAddr class to the below code

    public class ListArr {
    int indexOfEmptyCellInArr;
    ListView[] listArr;
    Context context;
    Activity activity;
    LinearLayout mainRelativeLayout;
    
    public ListArr(Activity activity, Context context, int numOFLists) {
        this.listArr = new ListView[numOFLists];
        this.indexOfEmptyCellInArr = 0;
        this.context = context;
        this.activity = activity;
        this.mainRelativeLayout = (LinearLayout) activity.findViewById(R.id.main_relative_layout);
    }
    
    public void AddListToListArr(String[] stringsOfNewList) {
        ArrayAdapter<String> arrayAdapter = new MyAdapter(context, stringsOfNewList);
        ListView listview = new ListView(context);
        listview.setAdapter(arrayAdapter);
        listArr[indexOfEmptyCellInArr] = listview;
        mainRelativeLayout.addView(listArr[indexOfEmptyCellInArr]);
    
        indexOfEmptyCellInArr++;
    }
    
    public void RemoveLastList(){
        int indexOfListToRemove = indexOfEmptyCellInArr - 1;
        listArr[indexOfListToRemove] = null;
        indexOfEmptyCellInArr--;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView with a custom Adapter that extends ArrayAdapter. It's a ArrayAdapter
I have a ListView with a custom adapter, and an animation in getView() for
I have a ListView with a custom list adapter (that extends BaseAdapter). My list
I have a custom dialog which extends Dialog and has a ListView inside its
I have Custom List to display image with it's name like below... public class
In my activity, I have an AutoCompleteTextView that gets its contents from my custom
I have a custom adapter for my ListView which has multiple TextViews. I want
Here's my aproach: I have a custom ListView containing a custom Adapter containing two
I have a ListView with custom Adapter . To be honest, I have many
I have a ListView with custom Adapter . I have to add at position

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.