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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:33:18+00:00 2026-06-02T11:33:18+00:00

For some reasons getView of my customized ArrayAdapter isn’t called and android displays an

  • 0

For some reasons getView of my customized ArrayAdapter isn’t called and android displays an empty list. I’ve already inserted cursor.getCount() in my datasource class to make sure my query isn’t empty.

Activity:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate called");

    setContentView(R.layout.conference_list_layout);

    Log.d(TAG, "create ConferenceDataSource");
    datasource = new ConferenceDataSource(this);

    Log.d(TAG, "open ConferenceDataSource");
    datasource.open();

    Log.d(TAG, "getAllUpcomingConferences");
    List<Conference> conferences = datasource.getAllUpcomingConferences();

    Log.d(TAG, "set ConferenceArrayAdapter");
    setListAdapter(new ConferenceArrayAdapter(this, conferences));
}

Datasource:

public List<Conference> getAllUpcomingConferences() {
    Log.d(TAG, "getAllUpcomingConferences called");

    List<Conference> conferences = new ArrayList<Conference>();

    Cursor cursor = database.query(
            DatabaseConstants.TABLE_CONFERENCES, 
            fields, 
            DatabaseConstants.CONFERENCE_START + ">" + (Calendar.getInstance()).getTimeInMillis(), 
            null, 
            null, 
            null, 
            null);

    cursor.moveToFirst();

    while(!cursor.isAfterLast()) {
        Conference conference = cursorToConference(cursor);
        conferences.add(conference);
        cursor.moveToNext();
    }

    cursor.close();

    return conferences;
}

private Conference cursorToConference(Cursor cursor) {
    Log.d(TAG, "cursorToConference called");

    Conference conference = new Conference();

    conference.setId(
            cursor.getLong(cursor.getColumnIndex(DatabaseConstants.CONFERENCE_ID)));

    conference.setStart(
            cursor.getLong(cursor.getColumnIndex(DatabaseConstants.CONFERENCE_START)));

    conference.setEnd(
            cursor.getLong(cursor.getColumnIndex(DatabaseConstants.CONFERENCE_END)));

    conference.setTopic(
            cursor.getString(cursor.getColumnIndex(DatabaseConstants.CONFERENCE_TOPIC)));

    conference.setCreator(
            cursor.getLong(cursor.getColumnIndex(DatabaseConstants.CONFERENCE_CREATOR)));

    return conference;
}

ArrayAdapter:

public ConferenceArrayAdapter(Context context, List<Conference> conferences) {
    super(context, R.layout.conference_list_item);
    Log.d(TAG, "constructor called");
    this.context = context;
    this.conferences = conferences;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Log.d(TAG, "getView called");

    LayoutInflater inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View view = inflator.inflate(R.layout.conference_list_item, parent, false);

    Date conferenceDate = new Date(conferences.get(position).getStart());

    TextView dayOfWeek = (TextView) view.findViewById(R.id.conference_list_dayofweek);

    dayOfWeek.setText(new SimpleDateFormat("E").format(conferenceDate));

    TextView date = (TextView) view.findViewById(R.id.conference_list_date);

    date.setText(new SimpleDateFormat("dd.MM.yyyy").format(conferenceDate));

    TextView time = (TextView) view.findViewById(R.id.conference_list_time);

    time.setText(new SimpleDateFormat("HH:mm").format(new Date(conferences.get(position).getStart())) + 
            new SimpleDateFormat("HH:mm").format(new Date(conferences.get(position).getEnd())));

    return view;
}

conference_list_layout.xml

<include layout="@layout/actionbar_layout" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:orientation="vertical">

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

</LinearLayout>

conference_list_item.xml

<TextView
    android:id="@+id/conference_list_dayofweek"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" />

<TextView
    android:id="@+id/conference_list_date"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/conference_list_dayofweek" />

<TextView
    android:id="@+id/conference_list_time"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/conference_list_date" />

Could it be, that the error is in the xml file. I’m using several customized ArrayAdapters and they all work fine and look nearly the same. I’ve read something about using match_parent instead of wrap_content but it didn’t work out.

  • 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-02T11:33:21+00:00Added an answer on June 2, 2026 at 11:33 am

    In your custom adapter(your probably extending ArrayAdapter) implement the getCount method and return the list of Conferences size:

    public int getCount() {
       return conferences.size();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reasons I have to use WebView in my Android application and part
For some reasons, my will_paginate collection is stuck on page 2. I have the
For some reasons this part where I fetch JSON data from following url will
What are some reasons why I wouldn't want to disable IIS logging completely for
I'd like to hear some reasons for using a ServerControl opposed to a UserControl.
I am developing a web application. For some reasons, I need to use external
The HttpModule works fine (hello is replaced with hello world) but for some reasons
I'm trying to use JQuery's autocomplete plug-in but for some reasons Internet Explorer is
I have problem with BWToolkit and XCode. For some reasons Xcode not recognize bwtoolkit
I think we may have trouble with our existing project. For some reasons we

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.