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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:06:54+00:00 2026-06-06T20:06:54+00:00

I am displaying images and text to a listview using a custom adapter, when

  • 0

I am displaying images and text to a listview using a custom adapter, when I run the activity for the first time it displays fine, but when I navigate to another activity and to change a value, when I come back to my listview activity it crashes. and it gives me the following error in Log –

(07-03 08:53:15.456: E/AndroidRuntime(574): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification.
Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(16908298, class android.widget.ListView) with Adapter(class stevey.sadc.system101.MobileArrayAdapter)])

Here is my code:

public class System101Activity extends ListActivity implements OnClickListener {
    public static final String S101 = null;
    private Button btnLogout,btnSignin,btnRegister;
    private TextView txtSharedName;
    public static final ArrayList<String> BookImages = new ArrayList<String>();
    public static final ArrayList<String> BookNames = new ArrayList<String>();
    public static boolean LogedIn = true;
    final Context context = this;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.storemain);
        this.btnLogout = (Button) findViewById(R.id.btnSignout);
        this.btnRegister = (Button) findViewById(R.id.btnSignUp);
        this.btnSignin = (Button) findViewById(R.id.btnSignIn);
        this.btnRegister.setOnClickListener(this);
        this.btnSignin.setOnClickListener(this);
        this.btnLogout.setOnClickListener(this);
        //txtSharedName = (TextView) findViewById(R.id.textviewLogName);
        ///////////////////////////New List//////////////////////////////////////////
        /*if(LogedIn){
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
        String sharedUsername = settings .getString("Sharedusername","null");
        txtSharedName.setText(sharedUsername);
        }else{
            this.btnLogout.setClickable(false);
        }*/
       Log.d("Logged IN", " "+LogedIn); 
        JSONObject json = JSONfunctions.getJSONfromURL("http://10.0.2.2/php/prrrrrrrrr.php");
           // http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=demo  
          BookNames.clear();
          BookImages.clear();
        try{

                JSONArray  earthquakes = json.getJSONArray("books");

                for(int i=0;i<earthquakes.length();i++){                        

                    JSONObject e = earthquakes.getJSONObject(i);

                    String BookName = e.getString("bookname");
                    BookNames.add(BookName);
                    String BookImg = e.getString("imageurl");
                    BookImages.add(BookImg);
                }       
            }catch(JSONException e){
                 Log.e("log_tag", "Error parsing data "+e.toString());
            }   

            setListAdapter(new MobileArrayAdapter(this, BookNames,BookImages));

    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {

        //get selected items
        String selectedValue = (String) getListAdapter().getItem(position);
        Toast.makeText(this, selectedValue, Toast.LENGTH_SHORT).show();
        Intent moreDetailsIntent = new Intent(System101Activity.this,MoreBookDetails.class);

        Bundle dataBundle = new Bundle();
        dataBundle.putString("SelectedBook", selectedValue);
        moreDetailsIntent.putExtras(dataBundle);
        startActivity(moreDetailsIntent);
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
        case R.id.btnSignUp:
            Intent signupIntent = new Intent(this,RegisterActivity.class);
            startActivity(signupIntent);
            break;
        case R.id.btnSignIn:
            Intent signinIntent = new Intent(this,SignInActivity.class);
            startActivity(signinIntent);
            break;
        case R.id.btnSignout:
///////////////////////////// Creating Alert Dialog/////////////////////////
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);

//set title
alertDialogBuilder.setTitle("LogOut");

//set dialog message
alertDialogBuilder
.setMessage("Are You Sure!")
.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, close
// current activity
//LogedIn = false;

    LogedIn = false;
Intent tabIntent = new Intent(System101Activity.this,MyTabs.class);
startActivity(tabIntent);
//Sign.this.finish();
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
});

// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();

// show it
alertDialog.show();
////////////////////////////////////////////////////////////////////////////
        }
    }   

}

Here is My Adapter.

public class MobileArrayAdapter extends ArrayAdapter<String> {
    private final Context context;
    private final String[] myBookNamelist = null;
    private ArrayList<String> MyBooks = new ArrayList<String>();
    private ArrayList<String> myBookImageurl = new ArrayList<String>();
     //ArrayList<HashMap<String, String>> myBookNamelist = new ArrayList<HashMap<String, String>>();
     //ArrayList<HashMap<String, String>> myBookImageurl = new ArrayList<HashMap<String, String>>();

    public MobileArrayAdapter(Context context,ArrayList<String> Bname,ArrayList<String> BUrl) {
        super(context, R.layout.mylist, Bname);
        this.context = context;
        this.MyBooks = Bname;
        this.myBookImageurl = BUrl;
    }


    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.mylist, parent, false);
        TextView textView = (TextView) rowView.findViewById(R.id.label);
        ImageView imageView = (ImageView) rowView.findViewById(R.id.logo);
        textView.setText(MyBooks.get(position));
        Bitmap bitmap = null;
        // Change icon based on name
        JSONObject json = JSONfunctions.getJSONfromURL("http://10.0.2.2/php/prrrrrrrrr.php");
           // http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=demo  
            try{

                JSONArray  earthquakes = json.getJSONArray("books");

                //for(position=0;position<earthquakes.length();position++){
                    JSONObject e = earthquakes.getJSONObject(position);
                    String BB = e.getString("bookname");
                    MyBooks.add(BB);

                    String UU = e.getString("imageurl");
                    myBookImageurl.add(UU);

                //}

            }catch(JSONException e){
                 Log.e("log_tag", "Error parsing data "+e.toString());
            }


            String s = MyBooks.get(position);
            String i = myBookImageurl.get(position);

            System.out.println(s);
            System.out.println(i);


            try {
                bitmap = BitmapFactory.decodeStream((InputStream)new URL(i).getContent());
                imageView.setImageBitmap(bitmap);
            } catch (MalformedURLException err) {
                // TODO Auto-generated catch block
                err.printStackTrace();
            } catch (IOException err) {
                // TODO Auto-generated catch block
                err.printStackTrace();
            }


            System.out.println("Bitmap image: "+position+"="+bitmap);


        return rowView;
    }
}
  • 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-06T20:06:55+00:00Added an answer on June 6, 2026 at 8:06 pm

    from your 2nd activity, when your data set is changed, send a broadcast notification.

    In your primary activity, register a broadcast receiver to listen for these changes, and call mListViewAdapter.notifyDataSetChanged() to reload the list view.

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

Sidebar

Related Questions

I have a view that will be displaying downloaded images and text. I'd like
This is a very common scenario: displaying images in a ListView which have to
i am using asynctask to fetch images from given url.these images are displaying in
I have the following code used for displaying several images changed on hover, but
I am using a ListView to display some images and captions associated with those
I want to use jQuery Thickbox for displaying my images but so far when
I am displaying a listview with a text view and image view. Image view
I am using the ASP.NET ajax slideshow extender tool for displaying images slideshow. I
I am using fckEditor as text editor. When i upload images thru it the
my app is displaying various text fields, date and time pickers and, most important,

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.