Tag: listview

change color of selected listview item

I want to change color of list item when it will press For that I did like below, list_item_selector.xml <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> Selected <item android:state_focused=”true” android:state_selected=”false” android:drawable=”@drawable/list_focused”/> Pressed <item android:state_selected=”true” android:state_focused=”false” android:drawable=”@drawable/list_selected” /> </selector> I have set the color in colors.xml like below, <drawable name=”list_focused”>#36C170</drawable> <drawable name=”list_selected”>#9EC136</drawable> and in my ListView I wrote […]

What is the difference between “int” and “long” argument in onItemClick in Android

When we implement OnItemClickListener, we have to implement onItemClick method which is an abstract method in OnItemClickListener interface. In onItemClick method there are four arguments. public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Toast.makeText(this, “Clicked on : ” + arg2 + ” long arg : ” + arg3, Toast.LENGTH_LONG).show(); } What I […]

how to get all elements of an ArrayAdapter?

I need get all elements of ArrayAdapter of an ListView. Like this: this.array = new ArrayAdapter<DocumentoDominiabilidade>(getActivity(), android.R.layout.simple_list_item_1); this.documentosDominiabilidade.setAdapter(array); // after many operations this.array.getAllElements() // return a List of Elements???? thank you

Android : ListView with Buttons -> OnItemClick do nothing

My problem come from ListView. Without Buttons, the .setOnItemClickListener of the ListView work well. (start an Activity) At time that I add Buttons into items of the ListView, Buttons are clickable but the items aren’t more clickable… I try to use myListView.setItemCanFocus(true); but it don’t work…

match_parent not working for ListView, if ListView is inside NestedScrollView

In my app I am using a ListView and it is inside a NestedScrollView. When I set height of the ListView to match_parent it does not cover the whole screen. I want that ListView to cover the whole screen. My XML file: <?xml version=”1.0″ encoding=”utf-8″?> <android.support.v4.widget.NestedScrollView xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:isScrollContainer=”false” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_gravity=”fill_vertical” android:clipToPadding=”false” app:layout_behavior=”@string/appbar_scrolling_view_behavior”> <LinearLayout […]

Having trouble animating listview layout

I want the items in the listview to slide in one at a time from left to right. I have the following in res/anim/slide_right.xml <?xml version=”1.0″ encoding=”utf-8″?> <set xmlns:android=”http://schemas.android.com/apk/res/android” android:interpolator=”@android:anim/accelerate_interpolator”> <translate android:fromXDelta=”100%p” android:toXDelta=”0″ android:duration=”150″ /> </set> And in my onCreate method in my ListActivity I have: LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(this, R.anim.slide_right); mList.setLayoutAnimation(controller); When I run […]

Android ListView array index out of bounds after filter

I think this is a question for experts. I get calls to getView() with positon out of bounds from the ListView data list. This happens when I use the Adapter filter. The filter publishResults() method populates the data with a filtered list which is smaller than the original list. The error seems to occur when […]

How to retrieve the clicked string from a listview using OnItemClick?

I’ve got some problem here. It looks simple and i keep searching for its solution. Unfortunately, i cant find anything. This is my problem…. What i’m trying to do is to get the string showed in the listview from an On item click method. This is my listview : – lol – hi – waw […]

Custom list items not responding to state_checked in selector

I’m going to begin by saying that I have read in detail almost every question on SO that I can find related to custom checkable list items and selectors. Many of them have similar issues, but none of the answers solve my problem. At a point in my app I present a custom list activity. […]

Slide In button effect of List View item for Android

I’m porting an iPhone app into android app and one of the difficulties is recreating functionalities that are native to iPhone. I found a native functionality of iPhone: When user execute slide touch on a listed item in list view, a delete button appears. Is there a version for this in android? Can it be […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.