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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:34:20+00:00 2026-05-27T15:34:20+00:00

My project simplify as below: First, I use application method Data.java to save data.

  • 0

My project simplify as below:
First, I use application method Data.java to save data.
It contain the data:

private ArrayList<String> data = new ArrayList<String>();
public int getsize() {
return this.data.size();
}
public String getdata(int i) {
return this.data.get(i);
}
public void adddata(String s) {
return this.data.add(s);
}

My AActivity class onCreate as below:

Data d = (Data)this.getApplication();
String test = new String[d.getsize()];
for(i = 0; i < d.getsize(); i++) {
test[i] = d.getdata(i);
}
//to show in list
DataAdapter = new DataAdapter (this, test);
setListAdapter(DataAdapter);

And when button is click, startActivity the BActivity class.
In BActivity class, the code as below:

Data d = (Data)this.getApplication();
d.adddata("newdata");
finish();

And AActivity class onResume() as below:

@Override
public void onResume(){
super.onResume();
this.DataAdapter.notifyDataSetChanged();
}

But why the list is not update?
I confirm the data has be save.

My DataAdapter:

public DataAdapter(Context ctxt, String[] d) {
this.data = new String[d.length];
myInflater = LayoutInflater.from(ctxt);
int i;
for(i = 0; i < d.length; i++) {
data[i] = d[i];
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewTag viewTag;
if(convertView == null) {
convertView = myInflater.inflate(R.layout.row_bookmark_list, null);
viewTag = new ViewTag((TextView)convertView.findViewById(R.id.tv));
convertView.setTag(viewTag);
}
else {
viewTag = (ViewTag) convertView.getTag();
}
viewTag.tv.setText(data[position]);
}
class ViewTag {
TextView tv;
public ViewTag(TextView t) {
this.tv = t;
}
}
  • 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-27T15:34:21+00:00Added an answer on May 27, 2026 at 3:34 pm

    Add your new data directly to the adapter not to ‘d’. The adapter keeps its own internal data which means that whatever changes you apply to your ‘d’ has no impact on the adapter.

    For example:

    List<String> itemsList = new ArrayList<String>();
    ArrayAdapter aa = new ArrayAdapter(..., itemsList);
    ...
    itemsList.add("new item"); --> wrong!
    aa.notifyDataSetChanged(); --> nothing changes, you wrongly added the item to itemsList
    

    you have to deal directly with the adapter:

    aa.add("new item");          --> correct
    aa.notifyDataSetChanged();   --> the adapter will reflect the change
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making pretty heavy use of reflection in my current project to greatly simplify
To simplify this test case, I created a new default .NET MVC project in
I'm thinking about throwing away my DB in my next project to simplify development/evolution.
Are there any free tools to help simplify working with an NHibernate project in
I'm doing a project. I'm not going to details but I will simplify my
Project layout: /project_a /shared /project_b /shared /shared project_a and project_b both need to contain
I simplify my question. Should I create test files in related project or separate
Can I simplify this statement with a lambda expression? var project = from a
I'm going to simplify my route declaration around of my asp.net mvc project. So
I'm working on a tool to simplify an application's deployment. Hence I'm aiming to

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.