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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:33:19+00:00 2026-05-20T02:33:19+00:00

I have got an app that saves audio on sd card. I’ve created a

  • 0

I have got an app that saves audio on sd card. I’ve created a listview which retrieves the filesnames from the sdcard. I’m trying to set a listener so when the file name is clicked I can launch another intent that plays that file. when I try to set the listener and pass in a new OnItemClickListener() eclipse is red underlining it. I understand that I have to implement the onItemclick(), this is where I think the intent ought to go.

Code:

package com.tecmark;

import java.io.File;
import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;

public class SdGetList extends Activity {
    private ListView lv1;
    private String[] lv_arr;
    private ArrayList<String> arr;
        
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.listlayout);
        arr = new ArrayList<String>();

        File sdCardRoot = Environment.getExternalStorageDirectory();
        Log.i("root on sd =", ""+ sdCardRoot.getPath());

        for (File f : sdCardRoot.listFiles()) {
            if (f.isFile()){
                String name = f.getName();
                arr.add(name);
                Log.i("arr is empty?******", ""+arr.isEmpty());
            }
            else {
                Log.i("file", " no file");
            }
            Log.i("arr******", ""+arr.size());
        }
        lv_arr = new String[arr.size()];

        for(int i=0 ; i<arr.size();i++) {
            lv_arr[i] = arr.get(i);
        }

        lv1=(ListView)findViewById(R.id.ListView01);
        // By using setAdpater method in listview we an add string array in list.
        lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr));
        lv1.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            }
        } );
    }
}
  • 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-20T02:33:20+00:00Added an answer on May 20, 2026 at 2:33 am
    list.setOnItemClickListener( new OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            Intent i = new Intent(ClassName.this,CourtDetailActivity.class);
            startActivity(i);
        });
    }
    

    this is the code is properly working I think you do not import blow Package

    import android.widget.AdapterView.OnItemClickListener;
    

    put this line to import section of the application

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

Sidebar

Related Questions

I've got a VB.NET WinForms app in which I have the need to refer
We have an app with an extensive admin section. We got a little trigger
We have got loads of options for php + MySQL + Apache combo... Which
I have got a python script which is creating an ODBC connection. The ODBC
I have got some code to load an assembly and get all types, which
I have got the following code from here to read an Excel file using
I've got a JNLP editor application that saves data to data files. I'd like
I've got a Qt App that uses QPointers to bring up new UI Dialogs
I've got a rails app that displays a list of items called modules. I'm
We have got a custom MembershipProvider in ASP.NET . Now there are 2 possible

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.