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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:31:32+00:00 2026-06-01T12:31:32+00:00

The is my code.I am here pupulating a list view with some array data.when

  • 0

The is my code.I am here pupulating a list view with some array data.when I am hitting the list I can be able to detect it by using a Toast.But I can’t able to call another activity.
in the place of Toast event.
public class ListView extends ListActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setListAdapter(new ArrayAdapter<String>(this, R.layout.foodjoint, RESTAURANTS));

    android.widget.ListView lv = getListView();
    lv.setTextFilterEnabled(true);


    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            // When clicked, show a toast with the TextView text
            Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
                    Toast.LENGTH_SHORT).show();
            myClickHandler();
        }
    });

    //      ListView restuList=ListView();

}

static final String[] RESTAURANTS = new String[] {
    "Restaurant 1", "Restaurant 2", "Restaurant 3", "Restaurant 4", "Restaurant 5",
    "Restaurant 6", "Restaurant 7", "Restaurant 8", "Restaurant 9", "Restaurant 10",
    "Restaurant 11", "Restaurant 12", "Restaurant 13", "Restaurant 14", "Restaurant 15"
};
public void myClickHandler() {
    finish();
    Intent gotoLIst=new Intent(ListView.this,MenuActivity.class);
    startActivity(gotoLIst);
}

and here is my XmL file

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/AliceBlue "
    android:padding="10dp"
    android:textSize="16sp"
    android:focusableInTouchMode="false"
    android:clickable="false"
    android:focusable="false" >

I need to call another activity @ listView onitemClick.

Actually I have used another activity which also use some list-view.and that activity contains some error.that’s why it’s not working. Thnx to Luksprog for helping me to find the answer.

  • 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-01T12:31:33+00:00Added an answer on June 1, 2026 at 12:31 pm

    You’ll probably want to finish() the current Activity after you start the new one:

    public void myClickHandler() {
        Intent gotoLIst=new Intent(ListView.this,MenuActivity.class);
        startActivity(gotoLIst);
        finish();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some code here that works great on IPv4 machines, but on our
Trying to truncate some code here and running into a problem: <script type=text/javascript> $(function()
Got this line of code here but its not working. private void Button_Click(object sender,
I've asked before about populating the list view with data from the database. Now
I want to make some kind of list of errors in C#, but I'm
Here's my current code. Basically it's populating my list with 'com.teslaprime.prirt.Task@44ef98aO' which I assume
I need some help here. Here is my situation: I have a binding list
enter code here I have a table on SQL server 2005 with bigint primary
The code here is X++. I know very little about it, though I am
enter code here Hi All, I have a simple windows service application that connects

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.