How can i transfer data one recyclerview to other recyclerview an activity and back.
When click one recylerview element it is showing another recyclerview and invisible clicked recyclerview element and opposite this prosess
enter image description here
simply remove item by using notifyitemremoved(pogition);
to first list of adapter and copy the item content.
then insert item to another recyclerview list adapter by
notifyiteminserted();
hope this will solve your problem;
Related
Hi I have two recyclerview in my app. I am loading data and fill the recyclerview with it. at bottom i have one button , lets say when user load the app, first recylcerview is visible, now user click on bottom button I am hiding first recyclerview and make second recyclerview visible. so now issue is Toast messages of first recyclerview's adapter is still appears even it is hide state.
I do not want to show Toast messages of first recyclerview when it is hide.
recyclerViewfirst.setVisibility(View.VISIBLE);
recyclerViewsecond.setVisibility(View.GONE);
Please follow these steps :
No need for setting visibility for RecyclerView.
Pass Empty ArrayList to your adapter and set adapter to RecyclerView.
Adapter mAdapter;
ArrayList<String> mList = new ArrayList<>();
mAdapter = new Adapter(context, mList);
recyclerViewsecond.setAdapter(mAdapter);
When data is there in ArrayList simply notify the adapter.
mAdapter.notifyDataSetChanged();
Don't pass any data for first RecyclerView when you click the button. That is you can display RecyclerView again with empty data.
no needs to hide the recycle view
just reset the adapter with another array list and notify the adapter
then first list data will replace with another list data
I have to create one screen which includes two lists
1) Recyclerview
2) expandable listview
When Recycler is Visible then i have to hide expandable list and when expandable list visible i want to hide Recyclerview. Everything is working fine. but i have some confusion i need to add swipe to refresh layout for both lists, how can i achieve these ? My problem is when there is no data in recycler view and expandable list swipe to refresh isn't working as expected . Any one have suggestions what should i do now?
You may use cache to store the data which is used in recyclerview and expandable list view formerly and then try refreshing the cache.
I have vertical RecyclerView for scrolling group of items and horizontal RecyclerView in each ViewHolder in order to scrol items inside of these groups. They are populated from database. Whenever item content is changed (user tap something or new data come from network) it is written to database and then notifyDataSetChanged() is called for the group cursor. I check if it is the same group in onBingViewHolder() and update items only if it is. But horizontal RecyclerView is scrolled anyway to the first item.
How could I prevent this behavior and why does it happens ?
BTW I'm writing result of this check in 'onBindViewHolder()` to the log and I can see that it is the same item.
Thanks.
RecyclerView creates new ViewHolder in order to perform animation. setItemAnimator(null) solved my problem.
In my android application, I have one spinner box and two edit text box for adding item.When I click on add button all the data will store in database and display in below Item list (listview display in my first image) by refreshing listview.
My problem is, when I click on add button at a time only one list is display and listview heading is also gone.
May be this problem is raised due to refreshing of listview.
I searched on google and found notifyDataSetChanged() method is used for refreshing list view but I don't know how notifyDataSetChanged() method is used in fragment?
Does anybody know how to use this method in fragment?
I am new to fragment. In my app all the java code is developed using fragment activity, and xml file is simple layout.(LinearLayout/RelativeLayout)
You can see my screen here:
1)First image show list heading.
2)Second image show List item.
You need to setAdapter again to your listview after adding new data. it will show new data int listview.
if not get, post your code where you setAdapter to listview.
You have to first add item in Arraylist/List which you passed in Adapter then after you can call below code..
adapter.notifyDataSetChanged();
listView.invalidateViews();
I have ListView which has many items(rows), onClick of any item goes to the DetailActivity which explains more about that particular item. If I want to see the detail of the next item, I have to come back to the ListView and click next item. How to design to see the next or previous item's detail from DetailActivity by swiping it left or right.
I assume that you have a Custom Object and ArrayList of this object.
You need to have an adapter to Show this Arraylist into Listview
When you clicked the list item you need to pass your object from ListActivity to your DetailActivity
I think you are doing this fine until this part.
Then now, you can use ViewPager and its adapter in your DetailActivity.
When you click the list item, you need to pass your Arraylist and your object index to the DetailActivity.
In the DetailActivity, get your Arraylist, set your List into ViewPager adapter, find your object via index(that you clicked) and set ViewPager page index as your wanted item index.
If you manage this correctly, you can slide details of your content. You can ask ma anything to make this clear.
There is a tutorial of Using the ViewPager: http://architects.dzone.com/articles/android-tutorial-using
You could go with a ExpandableListView. No need to open a new screen or doing something which becomes hard to manage like Fragments. The user can show/hide detail just by clicking on the item.
A view that shows items in a vertically scrolling two-level list. This
differs from the ListView by allowing two levels: groups which can
individually be expanded to show its children. The items come from the
ExpandableListAdapter associated with this view.