i am using list view to store date in sqlite database. In that the driver taking one trip.In that trip contain number of stops( Delivery, Begining of break, End of break, Begining of lunch, End of lunch, End of Trip). If i add the Begining of trip, all other stops will be added inside the trip,,,,, until the end of the trip......
Problem is
I have 2 pages first page having some listview.when i click the first row of the listview it show another set of listview in 2nd page. so each row in the main listview(1st page) have corresponging set of sub listview(2nd page) in the secong page.
All the stops are showing in the same page... any one help for my problem
I got the point regarding your problem. I think you want to have listview where you click on any trip item from trip listview and it display sub-items related with clicked item.
If my above assumption is right, then you should implement ExpandableListView.
Here are the examples which you can refers to and get more idea:
http://coderzheaven.com/index.php/2011/04/expandable-listview-in-android-using-simpleexpandablelistadapter-a-simple-example/
http://techdroid.kbeanie.com/2010/09/expandablelistview-on-android.html
Problem is I have 2 pages first page having some listview.when i click the first row of the listview it show another set of listview in 2nd page. so each row in the main listview(1st page) have corresponging set of sub listview(2nd page) in the secong page.
In your case you have to use ExpandableListView
check below below links, hope it will help you!
How to use ExpandableListView
Custom Expandable Listview
Android Expandable ListView simple Example in android.
How to create a custom ExpandableListView
Android-SlideExpandableListView
Related
I created a player list program, now according to the program I created, there is a button (at start_activity) when the program starts. clicking on this button will open a list created by the next "recyclerview". I have a question about how to put two buttons (to "start_activity") ("new stars" and "historical stars") and connect both to one recyclerview, the list design will be the same for both, only the names in the list will change . is it possible to use the same recyclerview for both to make it much simpler? how please show an example from the code. Thank you.
It's simple.
On first button click - get your list data & set an adapter in a recyclerview.
On second button click - get your other list data & set an adapter in the same recyclerview.
So your data will be updated. You just have to initialize new data & adapter on button click, then set adapter in the recyclerview.
I'm using Android Studio, and I have a listView that musts display an important amount of items. showing all of these items have a huge impact on performances. SO I would like to show them 10 by 10, and with a button show the 10 next items. After some researches, I found this android How to limit list items display in ListView and a button show more and this How to limit list items display in ListView by 10 and next 10after clicking next button. But these didn't lead me to a success. The 1st link looks easier but I didn't know where to put the code samples to make it work. Thanks for help !
You dont need to show "Load More" Button always. You can use Android's Recycler View for this. It will load only the data which can be shown on screen. Rest of the data will be loaded as you scroll down. And the view which is scrolled up (Vanishing views) are recycled automatically.
Check this links
https://developer.android.com/training/material/lists-cards.html
https://guides.codepath.com/android/using-the-recyclerview
https://www.binpress.com/tutorial/android-l-recyclerview-and-cardview-tutorial/156
First link question have a simple answer, If you made a custom adapter for populating listview then there will be a getCount() method which will return the number of items you want to show on listview. if you have not getCount() method then simply override it.
Link
there i(variable) have that value which number if items you want to show on listview, on refresh button click increment the value of i(variable) that will again refresh the whole listview and add the total number of items in listview which is the value of i(variable)
I'm building an android app and I'm trying to replace a list view with another list view if you click a button, like the notifications page on Instagram. On that page, if you click on the top "following" button it will show you a listview of what your followers have liked. If you click on the "you" button it will show you a listview of what people have liked your photos.
Any help would be greatly appreciated!
You can do it by following ways,
1. add Two listviews and can change the visibility as per your requirement.
2. On button click you can load the other data into same list view and can update your adapter in the same list view.
in 1 you have to load two list view at first which will consume more time if data is larger sure you can write a login in asynctask to load list views in background thread.
in 2 you have to update your adapter at the button so you will have to provide some progress bar of dialog for user while you list view is getting update.
You can use either of this whichever suites you best.
Simply , You don't need to switch Listview , you only need to switch adapters .
eg, you can switch to mFollowingAdapter when clicked on Following button and switch to mYouAdapter when you select "You" tab. that's it.
You should write a list, that has a custom adapter. This adapter will be able to display BOTH views you want to display.
If the data to be displayed is the same format (ie. both have an imageview next to a textview), you are in good shape.
When you want to switch to a different list, get the information you would like to display, replace the data in your the collection backing your list, then notify the list that the data has changed, and it should redraw.
So, this might look like:
create ArrayList() with data A
setup List, with this data and display
replace the ArrayList() with data B
call listView.notifyDataSetChanged
You can still do this if the Data A, and Data B have different views, in this case, you would need to handle this logic in your custom adapter.
after multiple try's, i'm using "mListView.setSelection(0);" to select the first row in my ListView when the list appears. But dunno why its not working. So how can I let the first row always clicked? Because in my application i have a listview on left side and a webview on right side. So i need that when my app launchs, the first row always selected so the webview loads the details of the first element per default. The data of the listView are loaded using a cursor Adapter that communicates with an SQLite Database.
This is a part of my code :
code
Try setting up an OnGlobalLayoutListener to your ViewTreeObserver, which sets the selection as soon as the layout is set. (Remember to remove the listener as soon as it's called the first time to avoid repeated calls.)
Check the android sources whether setSelection(int) handles unpopulated lists right.
You can try using smoothScrollToPosition(int position) it should work for you.
mListView.smoothScrollToPosition(0);
I am developing an android application.I have a listview in which i have 5 items.On each item click dere are 5 different views.On i the first item click i have made a registeration form.I want that when i click on second item that registeration form should be displayed ie data on the first item should be displayed.Is it possible,??.If yes can anyone guide me...how to implement this ..
below is my listview java class code
http://pastebin.com/tXDGdfb2
below is my provider activity java class code
http://pastebin.com/JdewveUp
Regards
Tushar Sahni
What you can do is check whether first one was clicked or not
If first item is clicked then on the click of second application, Create a view
which has both the fist and second Item view as sub views.
I hope that should work
Thanks
Himanshu