Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!

Ben van Jaarsveld

Greenhorn
+ Follow
since Jun 05, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ben van Jaarsveld

Hi sorry... yes... I have created a slider menu, but I would like the items in the menu to change to the people that I have inserted into the database..\

So when there is only 1 person's details added to the database... there will only 1 item on the menu, and as you add people, the lists will get longer

3 days ago
Hi guys...

Some advice please:

I am trying to create a slide menu with information that changes...

inside the app you can add personal information about people(into a database)... and I would like to create a listview inside the menu so that when selected the information is displayed in a fragment...

is this possible? and how would I go about it... any tutorials?

Thanks

Ben
3 days ago
Thank you for all your help...(Android Studio)

please excuse my terminology... it is late here and I think I am just tired... what I meant to say was...  "Cannot resolve symbol"

Anyway, in this case, there was a typo in my example -- should have been imgURLs rather than imgUrls



and that is what I got for just copying and pasting and not typing it out for myself..    
1 week ago
Thanks...

the

imgURLs

in your if statement then turns red ....i've tried making not final... but it didn't work
1 week ago
the

imgURLs

goes a couple of lines before:



so if i go to the getfilepaths function:




isn't this listfiles array, the array that populates imgURLs???

then that means that the listfiles array is empty???(am I wrong??)
1 week ago

Ron McLeod wrote:Does this stack entry: com.benvanj.android.outstagram.Share.GalleryFragment.setupGridView(GalleryFragment.java:165)
correspond to this line of code: setImage(imgURLs.get(0), galleryImage, mAppend); ??



yes it does...


Ron McLeod wrote:
If you are trying to view images for a directory which contains zero files, the imgURLs list will be empty.  Trying to reference element 0 (the first element in the list) will result in an IndexOutOfBoundsException since the list doesn't contain any elements.



Please tell me where to look, to find this information, then I could add files, and test it...
1 week ago
GalleryFragment.class
1 week ago

Stephan van Hulst wrote:

The obvious question is, are you sure that the directories you are listing have files in them?



I have even gone and changed the directories, loaded files... I made sure that ,that was not the problem...
1 week ago

Stephan van Hulst wrote:Welcome to CodeRanch!

The obvious question is, are you sure that the directories you are listing have files in them?

Can you show us the stack trace? I don't think the error has anything to do with the line you indicated.

There are many issues with your code you can fix though.

  • Don't create a class for the sole purpose of holding constants. Keep constants in the class that uses them. Make them static and final.
  • Don't use String or File to represent file paths. Use Path. This advice may be different for Android though.
  • Don't use more specific types than you need. Use List or Set for the return types of your methods, not ArrayList.
  • Don't name variables of a collection type "array". They're not arrays.
  • Prefer enhanced for-loops over indexed loops, or use the stream API.
  • Don't access a collection twice for the same element. Store the element in a local variable.
  • Don't perform unnecessary null-checks.
  • You don't need to keep track of a list of directories if you use Path, because you can just look up the parent directory.


  • Your problem is most likely caused by not using the Android API correctly though. You should probably be using Context, ContentResolver and MediaStore to look for images.



    Thank you for all this information.. I will definitely consider all this in future projects... the project that this pertains to is a tutorial on Youtube that is about 2 years(or more) old and I had/have a couple of problems with the code.. and sorting it all out is all I have been doing for about a week now... But I must say, doing it this way I have learned heaps and heaps... thanks for all the help
    1 week ago

    Ron McLeod wrote:

    Is that the complete stack trace?

    here you go Sir!!

    1 week ago
    Good day, thanks for this amazing portal...

    So I am learning how to create apps, and I have to write an Instagramclone.. so I followed the Coding with Mitch tuts on Youtube.. amazing stuff I learned a lot...BUT... I ran into a problem:

    So I have been tracking a problem and am not sure what is going on, Could you please tell me or show me, or even point me in the right direction...

    the error points to another section but I traced it to an empty array:

    so I have an Filepaths class:



    in another Class I call am getting my file directories and file paths:



    I also have a init Fuction to



    I have read up, followed other solutions, I even uploaded new data to the phone and Firebase...

    Please help, or just explain to me how I can search for a solution...

    Thanks
    1 week ago