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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:42:21+00:00 2026-05-26T18:42:21+00:00

I have a SimpleCursorAdapter Class, and I want to set an OnItemClick method everytime

  • 0

I have a SimpleCursorAdapter Class, and I want to set an OnItemClick method everytime when the row is clicked.

The method looks like this:

protected void onItemClick(AdapterView<?> l, View v, int position, long id) {
            Intent listIntent = new Intent(DetailsActivity.class,this);
            listIntent.putExtra("spendino.de.ProjectDetail.position",position);

            listIntent.setData(Uri.withAppendedPath(Uri.withAppendedPath(
                    Provider.CONTENT_URI, Database.Project.NAME), Long
                    .toString(id)));

            startActivity(listIntent);
}

but it always gives me an error on this line: Intent listIntent = new Intent(DetailsActivity.class,this);
It asks me to remove the arguments.

Can anybody help me with this?

UPDATED

@Override
        public View newView(Context context, Cursor cursor, ViewGroup parent) {
            View convertView = mInflater.inflate(R.layout.listitems, null);
            convertView.setClickable(true);
            convertView.setFocusable(true);
            convertView.setBackgroundResource(android.R.drawable.menuitem_background);
            convertView.setOnItemClickListener(ProjectsList.this);

            return convertView;
        }

the first solution gave me no error, but when I set the method on my View, it says that setOnItemClickListener is undefined for convertView

UPDATED

convertView.setOnClickListener(new OnClickListener() {
                 public void onClick(View view) {
                  Intent myIntent = new Intent(view.getContext(), DetailsActivity.class);
                  myIntent.putExtra("spendino.de.ProjectDetail.position",position);
                  myIntent.setData(Uri.withAppendedPath(Uri.withAppendedPath(
                            Provider.CONTENT_URI, Database.Project.NAME), Long
                            .toString(id)));
                  view.getContext().startActivity(myIntent);
                 }
                });

setOnClickListener isn’t working, I got an error on ‘position’ and ‘id’ how should I declare it?
Because those 2 things are mainly found on the setOnItemClickListener method

  • 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-26T18:42:22+00:00Added an answer on May 26, 2026 at 6:42 pm
    Intent listIntent = new Intent(DetailsActivity.class,this);
    

    this should be the other way around

    Intent listIntent = new Intent(this, DetailsActivity.class);
    

    or use MyActivity.this as first argument.

    covertView.setOnClickListener()
    

    use this.. onItemClickListener is for listView. but the convertView is only a list Item..

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

Sidebar

Related Questions

I have this scenario onResume of an activity: @Override protected void onResume() { if
I have this SimpleCursorAdapter for my ListView, the view is set from NewView. I'm
I have a database like this: table pepak, table category, table subcategory I just
I have a listview which I am populating with a custom SimpleCursorAdapter, each row
Have you managed to get Aptana Studio debugging to work? I tried following this,
Hi I'm having problem refreshing my listview after Async operation. I have a simplecursoradapter,
I have the following code snippet. public class ImageStoreActivity extends ListActivity { private DBHelper
I have: One MyListActivity class extends ListActivity setContentView(R.layout.mylist) ; Two xml files: mylist.xml and
Inside a fragment, I have a button which I want to trigger the filling
I have this code and I'd really liek to be able to get the

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.