0

I'm trying to use a horizontalscrollview with the code from this site.

The code seems to work fine. I get no Errors, the scrollbar is visible and I can also scroll in it but there are no Pictures inside.

Does somebody know why this can happen?

Shantha Kumara
  • 3,272
  • 4
  • 40
  • 52
Tschana
  • 13
  • 5

2 Answers2

1

The exception is pretty self-explanatory: it cannot find the pictures.

Aside from that: it's a pretty old post, the right way to achieve horizontal scrolling like this is to use RecyclerView with LinearLayoutManager set to HORIZONTAL.

atok
  • 5,880
  • 3
  • 33
  • 62
  • Can you maybe give me an example for the RecyclerView in form of a gallery? This would be really nice. – Tschana Nov 24 '14 at 15:32
  • That might help a little: http://javatechig.com/android/android-recyclerview-example – atok Nov 24 '14 at 15:33
-1

Do you have any pictures in /test directory on your device's SD card?

edit:

The sample code needs some pictures under /(your app's external storage directory)/test directory on SD card.

String targetPath = getExternalStorageDirectory() + "/test/";

Please note that getExternalStorageDirectory() won't return the root path of the sdcard. If you want access to the root. Refer: How can I get external SD card path for Android 4.0+?

And make sure that a permission is needed. http://developer.android.com/guide/topics/data/data-storage.html#filesExternal

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

or

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Community
  • 1
  • 1
hata
  • 11,633
  • 6
  • 46
  • 69
  • I've deleted the + "/test". Sorry, I Forgot to mention it. I thought I would get all other Images which are saved on my SD Card. – Tschana Nov 24 '14 at 15:28
  • this is not an answer – tyczj Nov 24 '14 at 15:34
  • @tyczj I'm sorry for I couldn't add a comment to Tschana's question directly because of lack of my reputation score. To clarify the problem, I firstly asked him a question. – hata Nov 24 '14 at 16:19
  • @Tschana I improved my answer. Please try to place some pictures under the app's external directory. The directory should something like /Android/data/(the app's packagename)/test . – hata Nov 24 '14 at 16:23