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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:37:24+00:00 2026-06-11T21:37:24+00:00

I am facing a problem while updating a ListView via an ArrayAdapter in a

  • 0

I am facing a problem while updating a ListView via an ArrayAdapter in a Android Fragment.

I have a method handling a .csv that is retrieved from a server. It parses the .csv and does the following:

for(int i =0; i< lines.length; i++){
    String[] words = lines[i].split(",");
        for(int j = 0;j<words.length; j++)
            if ( j%6 == 1 || j%6 == 2)
                getArrayAdapter().add(words[j]);

Using breakpoints, I can see that “words[j]” is a valid String. The method getArrayAdapter is the following:

private ArrayAdapter<String> getArrayAdapter(){
   if (aa == null){
        ListView lv = (ListView)   getCurrentActivity().findViewById(R.id.list);
        aa = new ArrayAdapter<String>(
                getCurrentActivity(),
                android.R.layout.simple_list_item_1);
        aa.setNotifyOnChange(true);
        lv.setAdapter(aa);
    }
    return aa;
}

If the “getArrayAdapter().add(words[j]);” is called, method “notifyDataSetChanged()” in ArrayAdapter is called, as it should:

@Override
public void notifyDataSetChanged() {
    super.notifyDataSetChanged();
    mNotifyOnChange = true;
}

Via its parent it reaches DataBaseObservable that does this:

public void notifyChanged() {
    synchronized(mObservers) {
        // since onChanged() is implemented by the app, it could do anything, including
        // removing itself from {@link mObservers} - and that could cause problems if
        // an iterator is used on the ArrayList {@link mObservers}.
        // to avoid such problems, just march thru the list in the reverse order.
        for (int i = mObservers.size() - 1; i >= 0; i--) {
            mObservers.get(i).onChanged();
        }
    }
}

The array of observers had an “AdapterDataSetObserver” that contains all kind of references to my adapter and ListView. I looked what happens in the onChanged() of AdapterDataSetObserver, but I do not really know what to look at.

My table_fragment.xml looks like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" 
  android:orientation="vertical" 
  android:id="@+id/top">
    <ListView android:layout_width="match_parent"
              android:layout_height="0dip"
              android:layout_weight="2"
              android:numColumns="2"
              android:columnWidth="30dp"
              android:id="@+id/list">
    </ListView>
</LinearLayout>

The xml of the activity containing the Fragment looks like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <fragment android:name="com.example.TableFragment"
              android:id="@+id/table_fragment"
              android:layout_weight="0"
              android:layout_width="match_parent"
              android:layout_height="0dip" />
</LinearLayout>

When looking in the log, nothing strange is there. All seems to go fine, but the screen does not show any of the strings.

What am I missing here? Probably missing something trivial, since I am a newbie to Android.

  • 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-11T21:37:25+00:00Added an answer on June 11, 2026 at 9:37 pm

    It turns out that layout_height of the ListView can be 0 (it auto expands). However, in the xml of the activity that contains the fragment, the layout_height could could not be set to 0 (it does not auto expand). I had put that on 0dip as well (after suggestion of Eclipse). Changing to “match_parent” did the job (despite the Eclipse warnings).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm facing a problem while deleting a record that is referenced by another table.
I am new to Android development and facing a problem while using AndEngine. I
I am facing problem while upgrading an Higher version over Lower version. I have
I have 2 classes Test(Base)and Program(child). Now I am facing some problem while downcasting.
I am facing a strange problem while running my application. I have a class
I'm facing character encoding problem while using @ResponseBody annotation. If I use response.getWriter().write() method
I am facing a problem while saving a .csv file from browser. I made
im new to android gaming and started andengine and facing problem while using createTiledFromAsset
I'm facing a problem while unit testing my forms. The problem is that data
I am facing the problem, that I have an C# (.NET) object shared among

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.