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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:47:06+00:00 2026-06-17T20:47:06+00:00

I have a problem thats probably very simple, but i dont quite understand what

  • 0

I have a problem thats probably very simple, but i dont quite understand what i am doing wrong. I have a listview, that is loaded as a file browser. This is whats supposed to happen when I click on any of the items.

protected void onListItemClick(ListView l, View v, int position, long id) {

File file = new File(path.get(position));

if (file.isDirectory())
{

if(file.canRead())
getDir(path.get(position));
else
{
new AlertDialog.Builder(this)
.setIcon(R.drawable.ic_launcher)
.setTitle("[" + file.getName() + "] folder can't be read!")
.setPositiveButton("OK", 
  new DialogInterface.OnClickListener() {   
   public void onClick(DialogInterface dialog, int which) {
    // TODO Auto-generated method stub
   }
  }).show();
}

}
else
{
new AlertDialog.Builder(this)

.setIcon(R.drawable.ic_launcher)

.setTitle("[" + file.getName() + "]")

.setPositiveButton("OK", 

  new DialogInterface.OnClickListener() {


   public void onClick(DialogInterface dialog, int which) {

    // TODO Auto-generated method stub

   }

  }).show();

}

}

But when i click on the items, nothing happens. I even checked the logcat to see if theres any activity when i click, but there is absolutely none. Do i need to somehow link this listener to my specific listview? Also if i need to post more information, just let me know. Thank you very much for your help!

NEW PROBLEM

AlertDialog show = new AlertDialog.Builder(this)
.setIcon(R.drawable.ic_launcher)
.setTitle("[" + file.getName() + "] folder can't be read!")
.setPositiveButton("OK", 
  new DialogInterface.OnClickListener() {   
   public void onClick(DialogInterface dialog, int which) {
    // TODO Auto-generated method stub
   }
  }).show();
}

}
else
{
new AlertDialog.Builder(this)
.setIcon(R.drawable.ic_launcher)
.setTitle("[" + file.getName() + "]")
.setPositiveButton("OK", 
  new DialogInterface.OnClickListener() {

   public void onClick(DialogInterface dialog, int which) {

    // TODO Auto-generated method stub

   }

  }).show();

}

On both of these, Im getting an error that the alertDialog is undefined.

  • 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-17T20:47:07+00:00Added an answer on June 17, 2026 at 8:47 pm

    Yes, you need to register the ListView with an OnItemClickListener

    E.g. like this:

    myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> list,
            View view, int position, long id) {
            // Your code goes here
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably a very trivial problem. I have an object that looks like this: @PersistenceCapable
I'm a newbie with WPF and c# and have a (probably very simple) problem.
I'm aware this is probably a very simple problem with a 1-line-of-code answer but
I have probably a simple math problem that I'm having surprisingly hard time figuring
My question is probably very simple but it could also be the case that
I have a strange problem which probably has a very simple solution, I just
I have a problem that I'm working on for quite some time now. I
(I have a problem that I illustrated in this question but had no correct
Probably, I haven't defined the problem very well. I don't seem to understand what
Okay my question is probably very simple for some of you but I can

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.