Android listview with buttons - android

I have a listview with custom listitem. I have bunch of textviews in Relative layout. And when I click on listitem it goes to different screen. Now I have added 3 buttons and toggle button to list item and I CAN NOT CLICK THE LIST ITEM. What am I missing :(

set focusable property of all the buttons to false and so that you can click on list and also touch event for all buttons will work

When the user clicks the row, the ListView will look for a widget implementing the Checkable interface. The RelativeLayout does not. An easy way to do that is simply to create your own CheckableRelativeLayout class. See http://www.marvinlabs.com/2010/10/custom-listview-ability-check-items/ for a full tutorial with code.
Also, the buttons and other items in your row layout should not be focusable. You can see other SO questions: Android Row becomes Unclickable with Button

Related

Android checkable menu item. Choosing the position of the CheckBox

I have a menu with checkable items. I want to put the CheckBox first and the Text to the right of the CheckBox. Any idea how to do this?
It's not possible to do this using menu items. What you can do, is use a custom Toolbar with a custom ImageView(aligned right) with the image src as the overflow icon (the one with 3 vertical dots). Also create a custom view(let's say checkBoxList) in your layout, which contains the text to the right of checkbox, the way you want it. Keep this checkBoxList aligned to the top right of your parent layout (super easy if you are using ConstraintLayout). Also, keep the visibility of this List to invisible. When overflow icon get's clicked, set the visibility of checkBoxList to visible. Also, have an onClickListener on the parent Layout, where you set the visibility of checkBoxList back to invisible( So that when the user clicks on anywhere outside checkBoxList, it closes).

OnLongClick() blocks the other clicks on the parent view

I have a strange behavior, I use a RecyclerView to display a list.
Each item of this list is composed of a LinearLayout containing 2 TextViews. (It's a classic configuration).
I have an OnClickListener on the LinearLayout and an OnLongClickListener on the second TextView.
The problem is that the OnLongClickListener prevents the "normal clicks" to reach the LinearLayout.
To summarize:
If I click on the first TextView, the Layout is clicked.
If I click on the second TextView, nothing happens.
You can't avoid this situation with your current xml file, you may need to make adjustment
Though if you want it with this design, you have to add OnClickListener to your second text that have OnLongClickListener and call inside it whatever you call on linearView.OnClickListener .
When you clicked on TextView just disable all click of linear layout because at a time one click listener will work.
linearlayout.setClickable(false);
linearlayout.setEnabled(false);

GridView delete multiple items like iphone apps uninstallation View

I have a GridView in which I am showing list of books. I have tried by creating custom layout and putting cancel button onlongclick listener of a view. But i am not able to apply a shaking animation to the items. Can anyone guide me how can i apply an animation to the items and make it similarly like iphone?
Now I want to provide feature to delete the Multiple items from the GridView like the View which shows as below:
I did lots of research for this ,but failed to get such kind of view in Android.
Can any one guide me for this?
You'll have to make a custom gridview for that. Place a button (x) on top of the grid item and set its visibility to invisible.. onLongPress of the grid item, make that button visible.. onclick of the button, delete that grid item by getting its id.
Hope I have given you a direction.

Android Expanding a single ListView Item

i have a list view with 3 buttons it. the functionality of those button would be that when clicked that single view should expand in height to show a text box. i havent done any code in the CustomAdapter of that listview to provide any reference to it.
What you just described is an ExpandableListView.
EDIT: Also, you can have the TextView's visibility set to "gone" and just become visible when the button is clicked.

how to scroll up when choose some item at item list in android?

I jave a list of item (linearlayout inside a scrollview where i add buttons vertically to linearlayout dynamically from the java code ) ? i need when i click on one button the item moves up (scroll up) , to make the item at the first of the screen ??!
Well I never did that, but from the ListView reference it seems pretty clear that set setSelectionFromTop is what you are searching for.
See also how-to-autoscroll-a-list-view-in-android

Categories

Resources