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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:35:00+00:00 2026-06-17T19:35:00+00:00

i have an issue with ArrayAdapter and listView . I’m adding strings to list

  • 0

i have an issue with ArrayAdapter and listView. I’m adding strings to list in ArrayAdapter which, as debugger showed me, works without a flaw, however i can’t see anything that is added on my listView.
Things i tried to do with it (based on similar questions):
+ add it inside runOnUiThread, but this is not helping or i am not using it correctly
+ invalidating view
+ setting adapter once more
+ adding to values and using `adapter.notifyDataSetChanged()
and I have no idea what can i do to make it work

Here’s my code if it helps:

public class RunnerApp extends Activity {

        private ListView listView;
    private ArrayList<String> values;
    private ArrayAdapter<String> adapter;
    private Intent newTable;
    private String newName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_runner_app);
        listView = (ListView) findViewById(R.id.mylist);
        values = new ArrayList<String>();
        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
       listView.setAdapter(adapter);
        adapter.add("x");
        adapter.notifyDataSetChanged();
    }

    //handled by android:onClick in layout file
    public void addTable(View v){
        newTable = new Intent(this, AddTable.class);
        startActivityForResult(newTable, 1);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data){
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode == 1 && resultCode == Activity.RESULT_OK && data != null){
            data.getData();
            Log.d("add", "got intent");
            newName = data.getStringExtra("com.example.runnerapp.NAME");
            Log.d("add", "string " + newName);
            Runnable run = new Runnable(){
                public void run(){
                    if(newName != null) {
                        values.add(newName);
                        adapter.notifyDataSetChanged();
                    }
                }
            };
            runOnUiThread(run);
        }
    }

    @Override
    public void onResume(){
        super.onResume();
        setContentView(R.layout.activity_runner_app);
    }
}


public class AddTable extends Activity {

    public final static String EXTRA_NAME = "com.example.runnerapp.NAME";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_table);
    }

    //handled by android:onClick in layout file
    public void addThisTable(View v) {
        Intent addTable = new Intent();
        EditText editText = (EditText) findViewById(R.id.addTableField);
        String name = editText.getText().toString();
        addTable.putExtra(EXTRA_NAME, name);
        setResult(Activity.RESULT_OK, addTable);
        this.finish();
    }

}
  • 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-17T19:35:01+00:00Added an answer on June 17, 2026 at 7:35 pm

    You should try taking out the setContentView(...) from the onResume() just because it will totally reset your view from scratch. It should really only be needed in onCreate()

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

Sidebar

Related Questions

I have an issue which I could not find answer for across the web.
I have a custom list adapter: class ResultsListAdapter extends ArrayAdapter<RecordItem> { in the overridden
I have been using the SeparatedListAdapter which is very well known and works perfectly,
I have a GridView backed by an ArrayAdapter . Everything works except for one
I have the following issue. I have a ListView and I am using a
I have a ListView that uses an ArrayAdapter. The items in the ArrayAdapter are
I have issue with table Reality which is not found, when I type db
I have a Custom Listview but i'm running into a weird issue when I
I have a file selector (which works as needed) but I wanted to add
I have issue to dynamically create list(ol or ul). The problem I face is

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.