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

The Archive Base Latest Questions

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

I have an array that successfully shows as a listview as the main activity.

  • 0

I have an array that successfully shows as a listview as the main activity. I’ve been using many tutorials in the past few days to try to find out the best way to start different activities from items clicked on this listview. I’ve seen everything from switch statements to calling a class by a variable, but nothing seems to work. I would possibly use an if statement but my list is over 120 entries. Any suggestions?

  • 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:47:58+00:00Added an answer on May 27, 2026 at 3:47 pm

    Why don’t you put the class as a parameter of the item ?

        package com.ybi;
    
        import android.app.ListActivity;
        import android.content.Intent;
        import android.os.Bundle;
        import android.view.View;
        import android.widget.ArrayAdapter;
        import android.widget.ListView;
        import android.widget.Toast;
    
        public class YbiListActivity extends ListActivity
        {
            public void onCreate(Bundle icicle)
            {
                super.onCreate(icicle);
                ClickableItem[] values = new ClickableItem[1];
    
                                // here you can add your label and your activity
                values[0] = new ClickableItem("Hello", YbiListActivity.class);
    
                ArrayAdapter<ClickableItem> adapter = new ArrayAdapter<ClickableItem>(this, android.R.layout.simple_list_item_1, values);
                setListAdapter(adapter);
            }
    
            @Override
            protected void onListItemClick(ListView l, View v, int position, long id)
            {
                ClickableItem item = (ClickableItem) getListAdapter().getItem(position);
                Intent intent = new Intent(YbiListActivity.this, (Class<?>) item.itemClass);
                startActivity(intent);
                Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
            }
    
            private class ClickableItem
            {
                public String itemLabel;
                public Object itemClass;
    
                public ClickableItem(String ilabel, Object iclass)
                {
                    itemLabel = ilabel;
                    itemClass = iclass;
                }
    
                @Override
                public String toString()
                {
                    return itemLabel;
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array that has been serialized by php, the result is: unserialize('a:2:{s:13:custom_basket;a:1:{i:280583837398;a:4:{s:12:product_name;s:0:;s:8:quantity;s:1:1;s:5:price;d:38.649999999999999;s:11:description;a:7:{s:2:id;s:12:280583837398;s:3:sku;s:0:;s:4:site;s:2:UK;s:12:condition_id;s:4:1000;s:14:transaction_id;s:12:773563256018;s:8:platform;s:4:eBay;s:18:order_line_item_id;s:25:280583837398-773563256018;}}}s:6:basket;a:0:{}}')
I have an array that contains a list of vertices which I copy to
I have an array that looks like: $fields = array( f1 => array(test), f2
I have an array that has keys and values. For eg: Array ( [name]
I have an array that looks like $numbers = array('first', 'second', 'third'); I want
I have an array that is a member of a structure: $self->{myArray} = [value1,
I have a array that looks like this Array ( [provider] => Array (
I have an array that contains the RGB colour values for each pixel in
I have an array that I want to sort based on the value of
I have an array that looks like this: Array ( [0] => Array (

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.