android-listview

ListView divider not showing in Android 5

佐手、 提交于 2019-12-18 21:17:53
问题 I have a simple listview for which I have defined a custom drawable for the divider. I have defined the divider height to be 1dp. The listview is within a fragment. <shape android:shape="line" > <stroke android:color="@color/custom_color" /> <gradient android:height="1dp" /> </shape> It works great for all Android versions except L. Anything I'm missing? 回答1: You should use android:shape="rectangle" instead of android:shape="line" to make it work on every android version... (also change

How can I add blank space to the end of a ListView?

£可爱£侵袭症+ 提交于 2019-12-18 18:58:15
问题 I have a number of elements in a ListView that scroll off the screen. I would like there to be blank space at the end of the View. That is, the user should be able to scroll past the last element such that the last element is in the middle of the viewport. I could use an OverScroller, but I think that would only enable the View to have a bouncy effect like one often sees on the iPhone. Is there something I might have overlooked? The scrolled-to-the-botton screen should look something like

clicking on the fragment invokes activity behind it

半城伤御伤魂 提交于 2019-12-18 18:55:30
问题 Im guessing its something really simple, maybe a setting in listview or fragment. But I couldnt find solution for it for couple of hours now. So.. I have a listView like this <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/content" android:layout_width="fill_parent" android:layout_height="fill_parent" android:isScrollContainer="true"> <ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android

Correctly animate removing row in ListView?

本秂侑毒 提交于 2019-12-18 18:24:11
问题 The problem: (1) add a touch listener to rows in a listview so that on swipe. (2) swipe animation plays (3) rows get deleted in the backend, and (4) the animation plays without any flicker or jerkiness. By "flicker" I mean that the deleted row briefly shows after the animation finished. I suspect that something funky was happening with the animation listener, so I ended up doing the following (done in the order given): Do the animation and make it persist by setting setFillAfter and

Is it possible to add a scrollable TextView to a ListView?

99封情书 提交于 2019-12-18 17:14:14
问题 I have a ListView where each row has a fixed height. Every row contains, next to some images, a TextView. Sometimes, the text I want to display is too large and hence I would like to make it scrollable. So I added (based on Making TextView scrollable on Android) the following lines to my TextView text.setMaxLines(5); text.setVerticalScrollBarEnabled(true); text.setMovementMethod(ScrollingMovementMethod.getInstance()); This works fine if I use the TextView in isolation but not when I put the

Creating custom simple cursor adapter

故事扮演 提交于 2019-12-18 16:59:31
问题 I want to create a very simple cursor custom cursor adapter to facilitate changing the colors of row items on click. Using the following code private static int save = -1; public void onListItemClick(ListView parent, View v, int position, long id) { parent.getChildAt(position).setBackgroundColor(Color.BLUE); if (save != -1 && save != position){ parent.getChildAt(save).setBackgroundColor(Color.BLACK); } save = position; } I got the code from this thread https://stackoverflow.com/a/7649880

Creating custom simple cursor adapter

自古美人都是妖i 提交于 2019-12-18 16:59:13
问题 I want to create a very simple cursor custom cursor adapter to facilitate changing the colors of row items on click. Using the following code private static int save = -1; public void onListItemClick(ListView parent, View v, int position, long id) { parent.getChildAt(position).setBackgroundColor(Color.BLUE); if (save != -1 && save != position){ parent.getChildAt(save).setBackgroundColor(Color.BLACK); } save = position; } I got the code from this thread https://stackoverflow.com/a/7649880

Fixed and always visible footer below ListFragment

痞子三分冷 提交于 2019-12-18 14:38:16
问题 I'm trying attach a footer, that is fixed and always visible, to the bottom of a ListFragment. I'm currently doing it like this: @Override public void onActivityCreated(Bundle savedInstanceState) { // ... adapter = new MyAdapter(getActivity(), R.layout.list, dataList); ListView list = getListView(); View footer = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_add, null, false); list.addFooterView(footer); setListAdapter(adapter); }

Change the behaviour of a GridView to make it scroll horizontally rather than vertically

谁说我不能喝 提交于 2019-12-18 13:32:20
问题 I want to make a UI element like a GridView , I want it's complete functionality but want it to be horizontally scrollable rather than vertically. By horizontal scroll I mean it should be built that way and not put in a HorizontalScrollView . My would be Custom GridView will have fixed number of rows say 4-5 and the columns should be extensible based on number of items in the Adapter . You can think of it as the opposite of what the native GridView does, yet it should maintain the

How to use D-pad navigate switch between listview's row and it's decendants (Google-TV support)

雨燕双飞 提交于 2019-12-18 13:20:01
问题 I have a listview which has an imageview inside each list item, when user click on that imageview, it will pop-up a menu. It works very well on a normal android device with a touch screen. But now I want to support google-tv, which app should be control by D-pad. When I use D-pad to navigate through listview, only the entire row can be focus, I can't get the imageview inside listview be focus. I try to add android:focusable="true" to imageview, but it cause the entire listview can't receive