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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:04:26+00:00 2026-05-27T13:04:26+00:00

Im currently doing some android developer that lists items in a ListView , we

  • 0

Im currently doing some android developer that lists items in a ListView, we have created a WebView that add’s a JavaScript interface to our page and our page sends information via the JavaScript interface. this all works as expected, so we set up a class called HangoutManager that extends a BaseAdapter, we have implemented several methods in there such as add/remove and exists.

This all works fine and now were at the point where need to use the BaseAdapter to update the ViewList when there changes to the Array Stack.

We can’t seem to get it too work, the getView() function never get’s called to generate an item. here is some code.

onCreate

public void onCreate(Bundle savedInstanceState)
{
    //Call parent to construct the Activity
    super.onCreate(savedInstanceState);

    //Create Instance of HangoutManager, must be called here
    HangoutManagerList = HangoutManager.Instance(this);

    //Set the content view to the main ListView
    setContentView(R.layout.main);

    //instantiate the WebView
    CanopyWebView = new CanopyWebView(this);

   setListAdapter(HangoutManagerList);
}

HangoutManager

public class HangoutManager extends BaseAdapter
{
    public static HangoutManager _Instance;
    private ArrayList<JSONObject> DataSet = new ArrayList<JSONObject>();

    protected LayoutInflater Inflater;

    public static HangoutManager Instance(Context context)
    {
        if(_Instance == null)
        {
            _Instance = new HangoutManager(context);
            Log.v("HangoutManager", "Instance Created");
        }

        return _Instance;
    }

    public HangoutManager(Context context)
    {
        this.Inflater = LayoutInflater.from(context);       
    }

    public boolean remove(String id)
    {
        try
        {
            for(int i=0 ; i< DataSet.size() ; i++ )
            {

                if(DataSet.get(i).getString("id").equals(id))
                {
                    DataSet.remove(i);
                    Log.v("HangoutManager", "hangout Removed");
                    return true;
                }   
            }
        }
        catch (JSONException e)
        {
            Log.e("HangoutManager::exists",e.getMessage());
            return false;
        }

        return false;
    }

    public boolean add(String hangout)
    {
        try
        {
            JSONObject HangoutJson = new JSONObject(hangout);
            if(this.exists(HangoutJson.getString("id")))
            {
                this.remove(HangoutJson.getString("id"));
            }

            DataSet.add(HangoutJson);
            Log.v("HangoutManager", "hangout Added");

                    notifyDataSetChanged();

        }
        catch(JSONException e)
        {
            Log.e("HangoutManager",e.getMessage());
        }
        return true;
    }


    public boolean exists(String id)
    {
        try
        {
            for(int i=0 ; i< DataSet.size() ; i++ )
            {
                if(DataSet.get(i).getString("id").equals(id))
                {
                    Log.v("HangoutManager", "hangoutExists: " + id);
                    return true;
                }
            }
        }
        catch (JSONException e)
        {
            Log.e("HangoutManager::exists",e.getMessage());
            return false;
        }
        return false;
    }

    @Override
    public int getCount()
    {
        return DataSet.size();
    }

    @Override
    public Object getItem(int position)
    {
        return DataSet.get(position);
    }

    @Override
    public long getItemId(int position)
    {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup)
    {

        if(view == null)
        {
            view = Inflater.inflate(R.layout.item1, viewGroup, false);
        }

        //Get the JSONObject for the Item
        JSONObject entity = DataSet.get(position);

        //Set the JSONObject as the tag for the row
        view.setTag(entity);

        //return the view to be drawn
        return view;
    }
}

main.xml

<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:cacheColorHint="#00000000"
    android:id="@android:id/list">
</ListView>

item1.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent">

    <TextView
        android:id="@+id/text"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:background="#FFFFFFFF"
        android:gravity="center_vertical"
        android:text="@string/app_name"
        android:textColor="#FF000000"
        android:visibility="visible" />

</LinearLayout>

StackTrace (not error stacktrace)

  • http://pastebin.com/1ftkiLBF

The section about is where we attempt to break but it never breaks at that point, am we doing something wrong ?

Update

The application seems to crash sometime during the notifyDataSetChanged() calls.

  • 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-27T13:04:27+00:00Added an answer on May 27, 2026 at 1:04 pm

    You shouldn’t call the inflater like this.
    Use the following syntax to get an Inflater to use from your getView()

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

    Also about the stacktrace, it looks like your JS interface callbacks are executed in background. You cannot modify the data collection binded to the ListView nor call updateNotifyDataset() from a background thread.

    But you can ask the UIThread to do it for you by calling your add method like this:

    yourActivityInstance.runOnUiThread(new Runnable() {
        public void run() {
            yourAdapterInstance.add(newHangout);
    }});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing some testing with WCF and we currently have the following Server setup
I'm currently doing some GUI testing on a ASP.net 2.0 application. The RDBMS is
i'm currently doing some reports for SSRS, and i just confirm what i already
I am currently doing some socket programming using C/C++. To be able to use
We're currently doing some Word automation, and want to be able to insert a
I'm currently doing some last-measure optimizations, mostly for fun and learning, and discovered something
I am currently doing some network programming and had a couple questions concerning timeouts.
I am currently doing some kind of reporting system.the figures, tables, graphs are all
Currently I'm doing some unit tests which are executed from bash. Unit tests are
I'm currently doing something like this in some code I'm working on right now:

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.