User management UI - java

i am doing a project using android studio in which once user logins,images of the books in their cart should be displayed. But different users have different number of books in their account like one user may have one book in their account and other may have three books in their account. I can't do this using static xml as i don't know how many image view to put in xml design.so, if their are two books in user account, only two image view should be displayed.My friend suggested me to use stack overflow and list view. so , how can i do this??

You'll have to use ListView or RecyclerView which is advanced version of ListView.
To do so Create two XML files.
One that will hold the ListView. Something like this <LinearLayout><ListView/></LinearLayout>.
And other will have the contents of ListView, which in your case are Images.so create <LinearLayout><ImageView/></LinearLayout>.
with these two XML files you don't have to care about the number of images/books each user have.
In your main activity create a ListViewAdapter and assign this adapter to your first XML layout containing the ListView.
Now in you AdapterClass getView() Method, inflate the second layout and you can access the imageview. Here you'll set the Image to your ImageView.

Related

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

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

How to send data From One RecyclerView Item to load another RecyclerView using Nested JSON

I am developing a Cinema App, but I want to use 2 RecyclerViews, one has successfully loaded, it contains the list of cinemas, then I want when someone taps on any of the Cinemas it loads another list of RecyclerView containing Movies.
How can I deal with 2 RecyclerViews?
Am new in Android. Below is the link to the sample of codes:
This is the link of the sample codes
RecyclerView Item to Load Another RecyclerView with Nested JSON
You have to options here:
The two recycler views are displayed on the screen at the same time.
This will imply the data in the 2nd recylcler view need the ability to change multiple times.
Add this code in your onItemSelectListener from your cinemaRecyclerView
Cinema selectedCinema = cinemas.get(selectedPosition); // This is the selected cinema from the CinemaRecyclerView;
moviesAdapter.updateMovies(selectedCinema.getMovies);
In your MovieAdapter class add the following method.
public void updateMovies(List<Movie> movies){
this.movies.clear();
this.movies.addAll(movies);
notifyDataSetChanged();
}
The cinema recycler view is on one screen and the movies list is on the next screen.
Here you will need to pass the selected Cinema object to the next Activity/Fragment. Based on this selection you can directly instantiate your MoviesAdapter with the correct movies list.

Android - Add an item from one ListView to another ListView?

I have an app that shows news from a RSS feed. There is ListView-1 which loads the news and when you click on an item(news), it shows only the selected news in a seperated xml layout. On the ActionBar for the single news item layout, user can click on Add to Favourites.
I have another activity and layout file and a listview just for Favourites. How can I copy an item from one listview to another?
So, the user can add news from main ListView-1 to another list called ListView-2.
I cannot use intents for sending one list item.
I have been thinking of using SharedPreferences to share an ArrayList, but something else needs to be the solution.
You don't need intents, just separate view and data, keep news in the singleton class, for example NewsManager, and keep one list for all news, one for favourite news, and use favourite list in the ListView2 adapter

Can i change the value in a Text field on listview

I have started to manage the Points and Details of a sport competition. I have displayed Competitor's ID and Name from Database. But i need to Get the Points which they got at run time Dynamically.
And the List of competitors must be changed Dynamically for verity of Games. There are Various games like Tennis, Chess, Running and so on..
Every Game that contains different Players and different no.of players. Can we Use this with ListView?
I need to solve this problem of Giving the points to the Competitors..
You could use the listView.setAdapter(); to set the data on the listView. Also, you could add a TextView as part of the implemented getView(position, converView, view) and return it to the listView.
You could also have a tableLayout inside of the listView. You would have a seperate layout.xml file for the tableLayout. This would have 3 columns. And return this as part of the getView() method.
You Can use the ListAdapter with TextViews and Data place holder

Java ListView class?

What is the difference between a listview layout xml and a Listview Java class? I am trying to make it when a user inputs text and presses enter it comes on a set position on the right but when the user receives a reply it would show up on the left side of the list view. Like text messaging on android phones. Does anyone know how i can do this? With a java class or an xml layout? I want animations and dynamic content on the listview as well. Any ideas?
ListActivity provides you all the built-in features of and methods of ListView but only ListView can be added into the whole Activity. By using ListView in xml, you add multiple Views such as Buttons, EditText on the same Activity.
Basically, the xml is for seperating the design (the visuals) from the code (functionality).
Although you can do some funcationality via xml, it's usually better to do it in Java code in your class.
I guess you can create a ListView that will iterate through 2 different list enteries:
The first will show the data (the text in your case) on left and the second entry will show on the right. For each list entery you will create a different xml layout with widgets aligned to the left and right as needed.

Categories