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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:25:12+00:00 2026-06-10T21:25:12+00:00

I have a simple application that has 3 activities. The third activity is a

  • 0

I have a simple application that has 3 activities. The third activity is a ListActivity that lists movie titles and their respective gross and year, choosing any movie will display the values in the first activity. The second activity is where the user can add a movie to the ListActivity by filling up EditText fields and this is where I’m having problems.

So far, the examples I see involve use this line of code:

        SampleCustomAdapter adapter = new SampleCustomAdapter(results);
        setListAdapter(adapter);

        adapter.notifyDataSetChanged();

However, this line of code doesn’t work for my case since the class in the second activity extends Activity and NOT ListActivity.

So far, this is the code I have when I attempt to add the new entries to the List.

//if all edit text fields have values and are valid inputs  
if( titleFlag == 1 && grossFlag == 1 && yearFlag == 1){
    //fix stuff here
    //TODO ADD THE NEW MOVIE TO THE ARRAY IN STRINGS.XML

    ArrayList<MyMovies> movieList = new ArrayList<MyMovies>();
    MyMovies newMovie = new MyMovies();

    newMovie.setMovie(title);
    newMovie.setGross(gross);
    newMovie.setYear(year);
    movieList.add(newMovie);


    //go back to the main page after adding
    Intent intent = new Intent(this, com.Android.Lab7.Lab7_084106.class);
    startActivity(intent);
    finish();

}

I also tried adding the adapter.notifyDataSetChanged(); in the third activity after generating the list but to no avail. Oh, the third activitys’ onCreate looks something like this:

@Override
public void onCreate(Bundle savedInstanceState) {

    //create stuff
    super.onCreate(savedInstanceState);

    ArrayList<MyMovies> movieList = new ArrayList<MyMovies>();

    String[] movieArray = getResources().getStringArray(R.array.movieArray);
    String[] grossArray = getResources().getStringArray(R.array.worldwideGross);
    String[] yearArray = getResources().getStringArray(R.array.yearArray);

        ArrayList<MyMovies> results = new ArrayList<MyMovies>();
        // make sure the arrays have the same length
        for (int i = 0; i < movieArray.length; i++) {
            MyMovies sr = new MyMovies();
            sr.setMovie(movieArray[i]);
            sr.setGross(grossArray[i]);
            sr.setYear(yearArray[i]);
            results.add(sr);

       }


        SampleCustomAdapter adapter = new SampleCustomAdapter(results);
        setListAdapter(adapter);



    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    adapter.notifyDataSetChanged();

    //set stuff such that Page2 sends back a result to page 1
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            sendResult(position);   
        }
    });


}

I used the strings resource to store the array of titles, gross, and year since there’s a lot of them and it’s not practical that I hardcode them.

So basically I’m stuck on how I can update the List in the third activity from the second activity.

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

    Declare this in the third Activity.

    public static String title, gross, year;
    public static boolean newMovieAdded=false;
    

    Then when you are in the second activity do the following

    thirdActivity.title = MyEditText1.getText().toString();

    thirdActivity.gross= MyEditText2.getText().toString();

    thirdActivity.year= MyEditText3.getText().toString();

    if(!year.equals(“”))

    newMovieAdded=true;

    thats all. when you go to the third activity just write your code

         ArrayList<MyMovies> movieList = new ArrayList<MyMovies>();
    
        if(newMovieAdded){
            MyMovies newMovie = new MyMovies();
            newMovie.setMovie(title);
            newMovie.setGross(gross);
            newMovie.setYear(year);
            movieList.add(newMovie);
            newMovieAdded = false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that contains a main Activity, which has a very simple
I have a simple Android application that has an Activity with an Observable object,
I have a fairly simple C# application that has builds a large hashtable. The
I have a really simple Rails application that allows users to register their attendance
I have a simple application that has a single page with a button that
I have a very simple application that has only 2 view controllers. The initial
I have a simple Android application that has a TabBar and one of the
I have created a rails application that has a simple RESTful json API. This
I have a simple photo taking application that has the following design: [Consider the
I have a simple application that starts with a splash screen activity that plays

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.