android-listview

Conflicting Android error messages: The specified child already has a parent. You must call removeView() on the child's parent first

狂风中的少年 提交于 2020-01-01 10:10:04
问题 Originally I got this error: The specified child already has a parent. You must call removeView() on the child's parent first at customSection.addView(customLayout); So I added ((LinearLayout)customLayout.getParent()).removeView(customLayout); and now get java.lang.NullPointerException So if the child has a parent, and I must first remove the child from the parent, why does getParent() return null? I have an abstract fragment that allows derived classes to supply a custom layout for the list

How to get all children (visible and invisible) from a ListView?

女生的网名这么多〃 提交于 2020-01-01 09:55:58
问题 My problem is similar to ListView getChildAt returning null for visible children, but despite searching I cannot find a solution. I have a ListView with a Scroll. The ListView has 10 items, 7 of which are visible and 3 are hidden by scroll. I also have an external method (out of adapter) that must get all of the children from this ListView (e.g. using getChildAt() ). I need all 10 of the items, but the last 3 are null objects. I've tried code like the following: getListView()

Change Text Color in ListView

妖精的绣舞 提交于 2020-01-01 07:32:28
问题 I have a simple listview that is created with an Array Adapter and ArrayList; Is there anyway to to access a certain row in the the list view and then change the text color of the text view that resides in that row in the list view? I know how to change the text color of a textview but i'm having problems accessing the text view that is inside of the list view 回答1: If you look at the source for simple_list_item_1, you'll see that it is just a TextView. The source is in: <sdk-dir>/platforms/

Enable/Disable item selection at listview in multiple choice mode

点点圈 提交于 2020-01-01 05:22:04
问题 I have a listview registered for context menu in multiple choice mode: private void initListViewForContextMenu(){ log.d("FilesFragment", "initListViewForContextMenu()"); ListView listView = getListView(); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { ... The problem is that not all the items of my view should be selectable, only those showing a special icon should be available for selection. I don't know how to

How do I create a ListView with dashed / dotted line dividers in Android?

时光毁灭记忆、已成空白 提交于 2020-01-01 04:16:28
问题 I managed to figure out how to create a custom shape (with a dashed stroke) by creating a file called dash.xml inside of the /app/res/drawable/ folder: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:color="#534b4b" android:width="1dp" android:dashGap="2dp" android:dashWidth="1dp" /> <size android:height="1dp" /> </shape> Now I'm confused as to how to apply this shape to a ListView. I've tried the

Detect whether TextView in ListView is ellipsized

瘦欲@ 提交于 2020-01-01 04:14:07
问题 I have a custom Adapter that renders some items in a ListView. I need to show an icon on the ListView's items, if the item's text is ellipsized, and hide it if there's enough room for the text to finish. I have access to the button in getView method of my adapter (where I set the text) but the ellipses are not added immediately upon setting the text. Is there any way I can do this? Here's my TextView markup: <TextView android:layout_width="fill_parent" android:layout_height="wrap_content"

animate listView childs only once they appear

落爺英雄遲暮 提交于 2020-01-01 03:13:27
问题 I have a listView with about 20 items (dynamic items). I want to animate these items first they show up to user. something like Google+ cards. There are some points that I want to achieve: items animate only when the user starts to see them. items animate only once. (not every time user sees them) on fast scrolling items don't mess up to each other. animations start with a delay according to position of items. Up to now I have tried: LayoutAnimationController (this method didn't meet the

animate listView childs only once they appear

て烟熏妆下的殇ゞ 提交于 2020-01-01 03:13:16
问题 I have a listView with about 20 items (dynamic items). I want to animate these items first they show up to user. something like Google+ cards. There are some points that I want to achieve: items animate only when the user starts to see them. items animate only once. (not every time user sees them) on fast scrolling items don't mess up to each other. animations start with a delay according to position of items. Up to now I have tried: LayoutAnimationController (this method didn't meet the

Ripple effect does not show up sometimes

孤街浪徒 提交于 2020-01-01 01:54:14
问题 I defined a ripple drawable and set it as the background for the listview item view's background. It almost works fine but the ripple effect just sometimes does not show up upon press. Here is the ripple drawable code: <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:attr/colorControlHighlight"> <item> <selector> <item android:state_activated="true"> <shape><solid android:color="?android:attr/colorButtonNormal"/>

How to handle the fast-scroller on Lollipop 5.1?

北城以北 提交于 2019-12-31 17:56:10
问题 Background I've made a tiny library, which shows how to mimic the style of the stock contacts app of Android Lollipop, here. The problem It seems that on Android 5.1 , the fast scroller looks very different than the previous one, and it's too close to the right, so it's hard to use it. screenshot of Android 4.4 : Here's a screenshot on Android 5 : and on Android 5.1 : What I've found I've tried to go over all of the "what's new" section of Android 5.1, and also in some related classes docs,