I had adapter for GridView which has 2 ImageView and 2 TextView.
I setOnItemClickListener this GridView and it worked great.
I wanted add to this adapter another GridView(which has another adapter(with TextView and ImageView).
So, every field in main GridView has images, texts and small GridView. I can click "large" fields when small GridView is empty. When I add something to this small GridView it looks like I wanted but then I can't click "Large" fields, only these "small".
I tried to setFocusable, Clicable etc. to false but I can still click only "small" fields.
How can I fix this?
Surprisingly, it's working when I add:
holder.internalGrid.setFocusable(false);
holder.internalGrid.setFocusableInTouchMode(false);
in outer GridView adapter. I don't know why that does not work when I put this in xml.
Related
When I put my RecyclerView inside a NestedScrollView. The LayoutManager and RecyclerView return the same values for getChildCount() and getItemCount() (they are ALWAYS the same, and ALWAYS the max value of the ArrayList/MutableList).
I have a large dataset added to the RecyclerView's custom adapter. Say that it is 400 image thumbnails. getItemCount() should return 400, while getChildCount() should only return like ~20 image thumbnails that a RecyclerView can fit on a screen.
When I use RecyclerView under the NestedScrollView, the getChildCount() always returns 400. I think my RecyclerView is not recycling views like it is supposed to and that I actually have 400 thumbnails displayed at once, instead of 20.
Now, I know I should just use RecyclerView by itself. Most likely, the removal of the NestedScrollView will make RecyclerView work the way it is supposed to. But I need to implement the collapsing toolbar which is typically done with a NestedScrollView with the CoordinatorLayout.
Are there any workarounds to have a RecyclerView with a collapsing toolbar?
My implementation is similar to this.
It's working as it's intended to be. This means When you add a ReyclerView inside a NestedScrollView the RecyclerView will not recycler views instead it will create all the views. Since you have a large set of 400 items it is bad to add recycler view inside NestedScrollView. It will cause serious performance issues when scrolling down.
If you want to implement Collapsing Toolbar, you can still achieve the same with RecyclerView. I don't how your layout looks like. However, you can refer to this article to see how it can be done
I have implemented the recycler view in navigation drawer in android.This is working fine.I am able to switch between item by clicking on recycler view item.
but i am not able to change the background color for the selected item.please suggest me how to imeplement it.I have tried this so far.
1.Background Selector in RecyclerView Item
Tried to make recycler view clickable,focusable but didn't work
2.http://innodroid.com/blog/post/tracking-selected-item-in-recyclerview
implemented but didn't understand where to write the code for changing background
Please help me out.
What you really need to understand with RecyclerView is that it's not the same control as a Listview with a funky adapter.
RecyclerView does not exhibit many of the ListView's functionalities and whilst it's understandable to compare it to a ListView or a GridView (or event a StaggeredGridView), it shouldn't be confused with them.
With RecyclerView, the responsibilities of handling the "background change" selector relies on the underlying control that the RecyclerView is holding. It's also the same with onClick and many other perks you get for free in a ListView.
Why it is better (or worse) to use a RecyclerView to a ListView is a different matter that I won't go into but to fix your problem, in order to set a background selector on your RecyclerView, add this to the layout that you're inflating in your ViewHolder (i.e. the actual layout that's being used inside the RecyclerView, similar to your "list row item" that you would inflate inside an ArrayAdapter if it were a ListView):
android:clickable="true"
android:background="?android:selectableItemBackground"
Which should set the background appropriately.
Recycler view are recommend when you have very large items & wants to have a custom UI. If you want to display only few items the would recommend to use List View.
I want to swipe an image from left to right and right to left in an ListItem, I searched so many codes in online, none had solution for me, can anyone help me.
If I understand you correctly, you're looking for something like a ListView that swipes horizontally instead of vertically.
You want a ViewPager:
Here's an example:
http://developer.android.com/training/animation/screen-slide.html
On the adapter's instantiateItem() method (which more or less takes the place of the getView() method in the ListView adapters), simply inflate layouts that contain only your images, rather than text like is shown in the example.
http://developer.android.com/reference/android/support/v4/view/ViewPager.html
I need to create a layout with a list of checkboxes on the left and text on the right. However, I need them to be laid out in a very specific way. I've searched for such a layout in many places, but no success (the closest I got to what I want was this.
This is the layout I need for my list
Can I achieve this with a ListView?
You can do it using ListView easily.
You should create your own Adapter and override your getView there
and return a RelativeLayout with your components inside e.g. a Button and a TextView
and set this adapter into your ListView.
Cheers
Create your own layout for each item in ListView and ListAdapter for your ListView
Check this link http://saigeethamn.blogspot.com/2010/04/custom-listview-android-developer.html
Hope this helps you
I have the following question: I have a difficult layout that contain ListView. I need disable scrolling ability for ListView, because it's container (root Layout) have had ScrollView already, and I don't need a scrolls for ListView. I disable scrolls by android:scrollbars="none", but abilitity for scrolling would stay. I need that if ListView has 10 items that all items will be shown. How can I do it?
Can't you just use a LinearLayout with 10 elements instead of the ListView? It is not a good idea to have a ScrollView in another ScrollView.
Why do you still use the ListView? Create your own Layout for an item and load it several times (LayoutInflater, .addView(listItem)).