Tag: listview

ListView inside ScrollView is not scrolling on Android

I am having trouble with a scrolling ListView inside a ScrollView. I have an Activity which has some EditTexts in the top part and then a tab host with two tabs which have one ListView each. When the EditText views are focused, the soft keyboard comes up and as I have a ScrollView, the content […]

Android ListView headers

I have ListView that has some kind of events on it. Events are sorted by day, and I would like to have header with date on it for every day, and then events listen below. Here is how I populate that list: ArrayList<TwoText> crs = new ArrayList<TwoText>(); crs.add(new TwoText(“This will be header”, event.getDate())); for (Event […]

Showing empty view when ListView is empty

For some reason the empty view, a TextView in this case, always appears even when the ListView is not empty. I thought the ListView would automatically detect when to show the empty view. <RelativeLayout android:id=”@+id/LinearLayoutAR” android:layout_height=”fill_parent” android:layout_width=”fill_parent”> <ListView android:id=”@+id/ARListView” android:layout_width=”fill_parent” android:layout_height=”fill_parent”></ListView> <ProgressBar android:id=”@+id/arProgressBar” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_centerHorizontal=”true” android:layout_centerVertical=”true”></ProgressBar> <!– Here is the view to show if […]

Android List View Drag and Drop sort

I have a list of records in a listview that I want the user to be able to re-sort using a drag and drop method. I have seen this implemented in other apps, but I have not found a tutorial for it. It must be something that others need as well. Can anyone point me […]

RecyclerView vs. ListView

From android developer (Creating Lists and Cards): The RecyclerView widget is a more advanced and flexible version of ListView. Okay, it sounds cool, but I when I saw this example picture I got really confused about the difference between the two. The picture above can be easily created by ListView with custom adapter. So, in […]

custom listview adapter getView method being called multiple times, and in no coherent order

I have a custom list adapter: class ResultsListAdapter extends ArrayAdapter<RecordItem> { in the overridden ‘getView’ method I do a print to check what position is and whether it is a convertView or not: @Override public View getView(int position, View convertView, ViewGroup parent) { System.out.println(“getView ” + position + ” ” + convertView); The output of […]

How to Get a Layout Inflater Given a Context?

I am writing a custom implementation of a ListAdapter. In its constructor, I’m taking in a Context, a resource ID (i.e. R.id.xxx representing the layout file), and a list and a map (these contain the data). Now, the problem is that i will need a LayoutInflater to get the View object which is in the […]

Android, ListView IllegalStateException: “The content of the adapter has changed but ListView did not receive a notification”

What I want to do: run a background thread which calculates ListView contents and update ListView partially, while results are calculated. What I know I have to avoid: I cannot mess with ListAdapter contents from background thread, so I inherited AsyncTask and publish result (add entries to adapter) from onProgressUpdate. My Adapter uses ArrayList of […]

How to Animate Addition or Removal of Android ListView Rows

In iOS, there is a very easy and powerful facility to animate the addition and removal of UITableView rows, here’s a clip from a youtube video showing the default animation. Note how the surrounding rows collapse onto the deleted row. This animation helps users keep track of what changed in a list and where in […]

Horizontal ListView in Android?

Is it possible to make the ListView horizontally? I have done this Using gallery view, but the selected item comes to the center of the screen automatically. I don’t want the selected item at the same spot I clicked. How can I Rectify this Problem? My Idea was to set the ListView with horizontal scroll. […]

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