I have 2 Button and one ExpandableListView in my activity.On button click i need to get Child views which is expanded in expandable List view. In other way i need to get all the child views which is currently showing in expandable List. For your reference i have added some sample image. in that i have get count button. on click of getcount button i need to get which is expanded(Dell) and its child and that count also.
I would recommend you do not add extra buttons. Without code it is hard to give you an example of what to change in your code.
However, I would suggest you take a look at ExpandableListView#OnChildClickListener. The method should offer the functionality you are looking for. I quote the documentation:
Parameters
parent The ExpandableListView where the click happened
v The view within the expandable list/ListView that was
clicked
groupPosition The group position that contains the child that was
clicked
childPosition The child position within the group
id The row id of the child that was clicked
This should be sufficient to serve your needs!
Related
I have a problem with lists.
I want to implement a scrollable big list, each element of which contains a text on the left side and a NON-scrollable inner list on the right side. (for example: the name of the flat and the list of its inhabitants names)
Both lists should be filled from the cursors and contain an informatio about them: I want to have an oppurtunitz to get all cursos fields when I click an element of the inner list.
As far as I understood I's not possible to solve it with two ListViews. ExpandableListView does not pass me because I do not want to expand the first list, I want to have the inner list always visible.
Do you have any ideas how can I realize it?
Try using a ListView for your big list, and an empty LinearLayout in each item. You fill the LinearLayout of each item programmatically in the big list adapters getView(..) method, where int position is the item number.
See also: android nested listview
Edit: Or use an ExpandableListView, which items you expand programmatically without animation with expandGroup(int position, boolean animate). Prevent collapsing by setting an ExpandableListView.OnGroupCollapseListener, in which you expand the group again. (seems a bit hacky)
Dokumentation: https://developer.android.com/reference/android/widget/ExpandableListView.html
By following Handle Button click inside a row in RecyclerView
and Issue with CardView and OnClickListener in RecyclerView my code is working for both view i.e complete row and imageview inside row.
If imageview inside row is clicked then onclick of row item should not fired, but it happen following approach in given links
Like for ListView item if you give focusable="true" of view inside row then onItemClick is not fired, if view inside row is clicked (only onClick(View) is fired.
How to make it possible with Recycler view?
You may have better success using listeners so that you can "bubble up" those events to your Activity/Fragment. Then you should be able to keep things separate.
Here is an example: https://guides.codepath.com/android/Using-the-RecyclerView#attaching-click-handlers-using-listeners
I followed the tutorial to create one for click on the row, and then created another (on my own) to handle clicking on the button within the row.
I am making an app in which the 1st layout contains clickable List having 12 items
and on clicking of each item, the user goes to a new Activity that has Expandable list View.
And I have concerned the tutorial at https://www.youtube.com/watch?v=BkazaAeeW1Q
and do I need to make 12 Activities each containing an Expandable View or is it possible that one Activity containing 12 Expandable Views but only one Expandable view is visible at a time (and which among them is visible will be dependent on Item clicked on the List View of 1st layout)
Hope I am able to make my point clear?
Use List Fragment, by using fragment no need to create 12 activity ,you just replace the container with view.
Also we can make one expandable view at one time, check on child click and onGroupexpand method for that.
Just like a ListView but instead it doesn't scroll. Its content is added programatically via an ArrayAdapter. Is there any view that can be used for this purpose?
PS: Not LinearLayout, since it doesn't get its content from an adapter (I want the observer pattern)
Edit: Let me explain a little bit more. Suppose you need a list of items, but the list itself is not scrollable, what is scrollable is the screen.
That being said, the list of items should show ALL items, not a limited amount based on a fixed height. The way to go is LinearLayout as it is both non-scrollable and shows all items within itself.
But there is a third requierement. You don't want to add(View) directly, but instead, you want something similar to an ArrayAdapter so that you have a control of the items and their position, so you can handle on item click events based on their position. As far as I know, this can't be done using a LinearLayout. So my question is, does any view exist for this purpose?
You could try using a ListView, but disable scrolling, as described here
Put your layout inside a ScrollView and yes you have to use a Linearlayout. You need to set tag for each of your view that you add dynamically and whenever your view is clicked you can get it's position by view.getTag() and perform the required operation.
Note : Adding views at run time may affect performance.
I am new to the Android Development. And I am stuck with the Customized list view.
Actually, in my activity there is two customized list view say list1 and list2.
Each list view's row having CheckBox, TextView and Delete button.
Now, my problem is that if in list1, for any row if the check box button is checked then at that time I also have to checked the checkbox of list2's child also.
I don't understand how to access the list2's child into the list1.
Please help me.
Thanks in Advance...:)
Use the function setOnItemClickListener of list1. You can get the position of the value you have selected. Take that position and use it to select the value in list2