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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:27:17+00:00 2026-06-07T20:27:17+00:00

I currently have an Android ListView class that displays a list of about 20

  • 0

I currently have an Android ListView class that displays a list of about 20 topics (Strings). I need to be able to click each button on the list and have that button open up a view specific to that topic.

For example, if this was a recipe list, then the layout for all of the recipe views could be the same, but when the user clicks a specific recipe from the list, then the program must load that recipe into the common layout and bring the user to that view.

I have the OnItemClickListener working I think, but I’m not sure how to implement the rest.

Will I need a new activity and layout for each recipe? Is there an easier way to implement this without making dozens of identical layout and activity files?

Also, how will I populate the view with the recipe?

Thanks much appreciated for any helpful thoughts!

— Some relevant code: The Listview Activity Code

listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, studiesList);  

    // Set the ArrayAdapter as the ListView's adapter.  
    mainListView.setAdapter( listAdapter );    
    mainListView.setClickable(true);
    mainListView.setOnItemClickListener(new OnItemClickListener(){

        public void onItemClick(AdapterView<?> a, View view, int position, long id) { 

            switch( position )
            {
               case 0:  Intent intent = new Intent(StudyActivity.this, pos.class); 
                        startActivity(intent);
                        break;

The SimpleRow.xml File: (The buttons for the list)

<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</Button>
  • 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-07T20:27:19+00:00Added an answer on June 7, 2026 at 8:27 pm

    What you need to do is make a serializable recipe class with some attributes, and then make new objects of that class for each of the 20 recipes.

    I assume you’d have something like

    public class Recipe extends Serializable{ 
    private String name; 
    private String ingredients; 
    
    public Recipe(String name, String ingredients){
    this.name = name;
    this.ingredients = ingredients;
    }
    

    }

    Then make an array list of these objects

    ArrayList<Recipe> recipes = new ArrayList<Recipe>();
    recipes.add(new Recipe("Chicken Curry", "Random cooking instructions"));
    

    and use that arraylist in your list adapter.

    Then in your onItemClickListener you’l need something like

    Intent i = new Intent(this, recipeDisplay.class)
    i.putExtra("recipe",  listAdapter.getItemAtPosition(position)); 
    

    and in your recipe display class just recieve the intent and use the object to populate your activity fields.

    Intent intent = getIntent():
    intent.getSerializableExtra("recipe");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a Service in Android that is a sample VOIP client so
I have a ListView of items that need to be checkable/uncheckable. I have set
I have a very simple ListView right now in a ListActivity that displays just
I currently have a ListView in Android with a LinearLayout as a header. I
Im currently doing some android developer that lists items in a ListView , we
I have a listView of contacts that I got from the Android ContactManager sample.
I have recently started making an Android app that requires a list of 20
I want to have a list of elements (using a ListView) and each element
I am Currently working on Android, and I created listview that loads Images from
I am writing a somewhat complex game engine in Android. Currently I have a

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.