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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:55:16+00:00 2026-06-12T17:55:16+00:00

I write an Android Application and I use a ListView and it works fine,

  • 0

I write an Android Application and I use a ListView and it works fine, but if I want to click on an Item then I want to start a second Activity with the selected Item. For this I want to use OnItemClick but it doesn’t work 🙁

MainActivity.java

package de.linde.listview;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View; 
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class MainActivity<T> extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        List valueList = new ArrayList<String>(); 

        for(int i=0;i<10;i++)
        {
            valueList.add("value" + i); 
        }

        ListAdapter adapter = new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_list_item_1,valueList); 

        final ListView lv = (ListView)findViewById(R.id.listview1);
        lv.setAdapter(adapter); 

        lv.setOnItemClickListener(new OnItemClickListener() {   //<-- Error1

            @Override
            public void OnItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3){  //<-- Error 2

                Intent intent = new Intent();
                intent.setClassName(getPackageName(), getPackageName() + ".Show_Activity"); 
                intent.putExtra("selected",lv.getAdapter().getItem(arg2).toString()); 
                startActivity(intent); 

            }

        });


    }

}

Here my Show_Activity.java

package de.linde.listview;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.widget.TextView;

public class Show_Activity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.anzeige);

        Intent intent = getIntent();

        ((TextView)(findViewById(R.id.textView1))).setText("Es wurde" + intent.getStringExtra("selected") + " gewählt!"); 
    }

}

I get the Error 1:

The type new AdapterView.OnItemClickListener(){} must implement the
inherited abstract method
AdapterView.OnItemClickListener.onItemClick(AdapterView, View, int,
long)

I get the Error 2:

The method OnItemClick(AdapterView, View, int, long) of type new
AdapterView.OnItemClickListener(){} must override a superclass method

What did I make wrong?

  • 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-12T17:55:17+00:00Added an answer on June 12, 2026 at 5:55 pm

    Try to remove @override before onItemClick method:

    lv.setOnItemClickListener(new OnItemClickListener() {   //<-- Error1
    
           // @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3){  //<-- Error 2
    
                Intent intent = new Intent();
                intent.setClassName(getPackageName(), getPackageName() + ".Show_Activity"); 
                intent.putExtra("selected",lv.getAdapter().getItem(arg2).toString()); 
                startActivity(intent); 
    
            }
    
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write application on android and windows which will use bluetooth. In
I want to write an application for Android devices that interacts with the surface
I want to write an application for Android, a card game that can be
I have tried to write an Android application with an activity that should be
I want to write an Android application to read and display PDFs. I don't
I use IntelliJ IDEA to write Android apps, and use the DDMS Windows application
I want to write a android application which needs data from the web. This
I am attempting to write an Android application that makes use of the GNU
I write android application. How can I use Certificate in https connection when I
I want to write an Android application that uses the Remember the Milk API

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.