How can I create a ListView of videos, and images? - java

How can I create a ListView of videos?
I explain myself a little better, I want to make an app with a listview that contains short videos.
I create an activity list_item where I want to put images and text. For example in the first list item I want you to put a thumbnail and a description, for example: horse accident and in the second list_item put another thumbnail with another description, for example: squirrel attack.
I know how to create a list view that shows the same image in all the list_items, but I don't know how to make a list view that contains different videos, images and text for each list_item.
The images, the video and are stored in the assets and raw folder, respectively.
Do you have any idea how to fix this?

Use this library for videos using ListView :
implementation 'cn.jzvd:jiaozivideoplayer:6.2.12'
use this link for documentation : https://github.com/lipangit/JiaoZiVideoPlayer

Related

Custom listview for image and text, or only text

I'm trying to build an app of my website(Just new to programming Java), getting data from my site is all going fine, but now i need to display it. I did some research online for the best way to do it(CustomListView), but coundnt find the solution yet, hope you guys can help me out.
The site i'm making an app of, is just a site where people can post text, or text with a photo.
Getting the text in my listview is going fine, but i also need images to display.
The problem is, how can i tell the Listview that it only contains text, so it wont display any image field, and how can i tell the ListView when there is a photo found by the post,that it also should display that one?
You can use a tag if the post contains an image or not for example if the data is in JSON form just set a tag
[{contains_image:"null"},{contains_image:"yes"}]
Then in your adapter check this tag if the result is a null set visibility gone
You have to create a layout containing a listView.
You have to create an xml lyout corresponding to one row of your list view.
You have to create an adapter which will populate data to insert in your listView
You have to create an onClickListener on your button to add data in your list
If you are using an ArrayAdapter or a CursorAdapter, add the new item you created to the list or the cursor used by your adapter and (notifyDataSetChanged() is automatically called), so your adapter will update the listview
Source : http://developer.android.com/resources/tutorials/views/hello-listview.html
Have at look at this article : http://www.androidhive.info/2014/07/android-custom-listview-with-image-and-text-using-volley/
Once you are go through with above set placeholder image which will be show for the items that do no get dynamic images from your server response.

How to get the uri of the images stored in the phone and return them in a String[]

I am trying to create a custom gallery with a single select option. I've used the code provided by google docs to create a GridView that contains the images contained in drawable.
Now I want to change it by making the GridView show all the images stored in the phone.
To get all images from the phone you need to query the android.provider.MediaStore
First make sure you have the AndroidPermission.READ_EXTERNAL_STORAGE, then get the thumbnails for the grid.
Here is a simple way to do this:
HERE
Hope this helps.

Android - Can you 'auto create' layouts while app is running?

I'm trying to create a scrollabe friends list. I'm grabbing the information for each friend off of a text file (profile pic, name, age, etc.)
So in my prototype I used different nested layouts to create one single friend entry. And to fill the list I just copied the most parent layout of my first friend and changed or adjusted the profile pic and the other text information.
What if, while the app is running, I need to update my friendslist and add another friend to the list.
How do you realise something like that?
Go for a recycler view or a scrollable list view to make a list and dynamic. You can check slidenerd's video tutorial on youtube. They are really helpful for a beginner to start any kind of app.

How I can manage to show large sum of images in imageview of fragment?

I am developing a book app. It contains 13 chapters, each chapter contains many (7-10) exercises and each exercise contains many images(10-15).
I have created main menu activity which contains all the 13 chapters.
I have created 2 fragments, one to show exercises and 2nd for the imageview.
1) Which is the best place to put 400 images? they r very small size like 10kb per image so I want include them in apk. in raw i can access them through their id, while i can create chapter folders in asset which contains exercises folders which contain images.
but then i would have to use asset manager.
2) How I can create arraylists of exercises for each chapter? in xml of in java? and how i can use one fragment to access these arraylists and display exercises as buttons so user can click on it to load images.
3) how I can load multiple (10-15) images in a single imageview in scrollview for each exercise?
if u need to ask for any details please do ask.
1) I recommend you to use UniversalImageLoader to manage the images.
2) You can stock the information in json files and the parse them with Gson or similar (It would be better if you stock it in a database and then use an ORM to retrieve it).
3) You can't. You should use ListView against.

Modifying single list items

I have a ListView, displaying some items, containing an ImageView filled with a standard image at first and a line of text.
What I wanna do is downloading one thumb after another with an AsyncTask and step for step change the standard image with the downloaded one. How to realise this?
The ListView contents are managed by an enhanced ArrayAdapter.
greetz
EnflamedSoul
If I understand you correctly you're interested in a LazyList. This example shows a stub for the image, then downloads some thumbnails as the user scrolls down and caches these onto an SD card. The next time the images will be loaded from the SD card.
Lazy load of images in ListView
I personally used Fedor's example and it worked well.

Categories