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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:38:23+00:00 2026-05-14T21:38:23+00:00

I’m passing data to a ListView to display some restaurant names. Now when clicking

  • 0

I’m passing data to a ListView to display some restaurant names. Now when clicking on an item I’d like to start another activity to display more restaurant data. I’m not sure about how to do it. Shall I pass all the restaurant data in a bundle through the intent object? Or shall I just pass the restaurant id and get the data in the other activity? In that case, how can I access my restaurantList from the other activity? In any case, how can I get data from the restaurant I clicked on (the view only contains the name)?

Any help, pointers welcome!

ListView lv= (ListView)findViewById(R.id.listview);

lv.setAdapter( new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,restaurantList.getRestaurantNames()));

lv.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

        Intent i = new Intent(Atable.this, RestaurantEdit.class);
        Bundle b = new Bundle();
        //b.putInt("id", ? );
        startActivityForResult(i, ACTIVITY_EDIT);
    }
});

RestaurantList.java

package org.digitalfarm.atable;
import java.util.ArrayList;
import java.util.List;

public class RestaurantList {

    private List<Restaurant> restaurants = new ArrayList<Restaurant>();

    public List<Restaurant> getRestaurants() {
        return this.restaurants;
    }

    public void setRestaurants(List<Restaurant> restaurants) {
        this.restaurants = restaurants;
    }

    public List<String> getRestaurantNames() {      

        List<String> restaurantNames = new ArrayList<String>();

        for (int i=0; i<this.restaurants.size(); i++) {
            restaurantNames.add(this.restaurants.get(i).getName());
        }

        return restaurantNames;
    }
}

Restaurant.java

package org.digitalfarm.atable;

public class Restaurant {

    private int id;
    private String name;        
    private float latitude;
    private float longitude;

    public int getId() {
        return this.id; 
    }

    public void setId(int id) {
        this.id = id;
    }       

    public String getName() {
        return this.name;   
    }

    public void setName(String name) {
        this.name = name;
    }

    public float getLatitude() {
        return this.latitude;
    }

    public void setLatitude(float latitude) {
        this.latitude = latitude;
    }

    public float getLongitude() {
        return this.longitude;
    }

    public void setLongitude(float longitude) {
        this.longitude = longitude;
    }
}
  • 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-14T21:38:24+00:00Added an answer on May 14, 2026 at 9:38 pm

    You can not access data from other activities. If you need data in the activity that is started through clicking on the item in the list pass it to the new activity through the message bundle.

    If you pass only the id to the next activity you could reload the restaurant from a database or from the internet but you can not retrieve it from the list used in the first activity.

    If the restaurants are heavy to create objects you could implement you own application subclass and attach the restaurant list to this application subclass. Now you can access the list like this:

    shopList = (YourSubclass)getApplication().getRestaurantList()

    This would result in your shoplist being in the memory the wohl runtime of you application even if the app is in the background and all activities are paused.

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

Sidebar

Related Questions

No related questions found

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.