android-listview

ViewPager inside ListView

百般思念 提交于 2019-12-17 16:35:11
问题 Is there a way to add a viewpager as a listview item? I want to add it as a "header" on top of my listview before all real list items follow. I tried using addHeaderView() or declaring multiple view types in my list adapter, however, the viewpager never shows up whatever way I try. Has anyone done something similar? Help! 回答1: Quoting Dianne Hackborn, ViewPager is "just not intended to be used as an item in a list" 回答2: Do not use wrap_content , try to calculate and set ViewPager size

ListView with ArrayAdapter and ViewHolder adding icons to the wrong item

有些话、适合烂在心里 提交于 2019-12-17 16:30:55
问题 I have a dynamic ListView which uses an ArrayAdapter . When a name is selected from a spinner, the name together with an icon showing whether they are male or female gets added to the ListView . Mostly everything is good (the name gets added to the list correctly, together with an icon). But the icon showing the sex gets added to the wrong item in the ListView . The name gets added to the bottom of the list, but the icon gets placed at the name at the top of the list. I don't know if it's the

Android: Difference between getCount() and getChildCount() in ListView

十年热恋 提交于 2019-12-17 16:18:59
问题 What is difference between getCount() and getChildCount() in ListView ? 回答1: getCount() returns you a count of items in Adapter (total in list), getChildCount() is a ViewGroup method that returns you number of subviews. ListView actively reuses views so if your list has 1000 items getCount() will return 1000, getChildCount() - around 10 or so... 回答2: getCount() is the number of items in the adapter while getChildCount() refers to the ViewGroup's method that returns the number of the views

Add Items to ListView - Android

末鹿安然 提交于 2019-12-17 15:49:10
问题 This is my first experience with android. I'm trying to add items to my ListView. I use Tabs, and the only way to see that the item was added is to change tab and then come back to the first tab. I searched around, and I've always found adapter.notifyDataSetChanged(); but doesn't work for me. I have created the project with, as I said, Fixed Tabs + Swipe. I simply want to have listviews which rows have an EditText, a Spinner and a Button. On the bottom of the Fragment used for the tab, I have

delete multiple items in custom listview

三世轮回 提交于 2019-12-17 14:53:56
问题 I want to create a custom listview in which every single row has a textview and an imageview(which i'll use to check/uncheck the list items) as shown in the following figure: I want to delete multiple items from the list. How to achieve this ?? Can you please provide any tutorial or reference or link to learn this ?? 回答1: This is how i created my custom listview with ease: import java.util.ArrayList; import java.util.Arrays; import java.util.List; import android.app.Activity; import android

Custom ListView adapter, strange ImageView behavior

会有一股神秘感。 提交于 2019-12-17 14:23:28
问题 I have a custom ListView Adapter , with which I'm creating rows for a list. My problem is though, that it doesn't seem to be distinguishing the ImageView s, from each other. It seems to be randomly picking ImageViews to chuck into place as I scroll up and down. The text information (omitted from this snippet) does not break. It works as one would expect. Here is the relevant method of my Adapter : public View getView( int position, View convertView, ViewGroup parent ) { View v = convertView;

Custom ListView adapter, strange ImageView behavior

限于喜欢 提交于 2019-12-17 14:23:18
问题 I have a custom ListView Adapter , with which I'm creating rows for a list. My problem is though, that it doesn't seem to be distinguishing the ImageView s, from each other. It seems to be randomly picking ImageViews to chuck into place as I scroll up and down. The text information (omitted from this snippet) does not break. It works as one would expect. Here is the relevant method of my Adapter : public View getView( int position, View convertView, ViewGroup parent ) { View v = convertView;

Android ListView in Fragment

余生长醉 提交于 2019-12-17 12:19:42
问题 I am trying to create a list of items which contains an image and some description for the image in each individual. After which, the list will be place in a fragment inside the application. Can anyone guide me to create it? I am not too sure how can I do it without the ListActivity . 回答1: It seems like your Fragment should subclass ListFragment (not ListActivity). onCreateView() from ListFragment will return a ListView you can then populate. Here's more information on populating lists from

Disable Scrolling in child Recyclerview android

做~自己de王妃 提交于 2019-12-17 10:42:32
问题 I have a layout consists of a Parent RecyclerView with a sub Recyclerview in it i know that it is not good to put a list inside another list but i have to so that i can use the sub list features like swiping and drag and drop My issue is that the child Recyclerview gain focus and stops the parent from scrolling if the touch point was on it simply i want if the touch was vertically on the child Recyclerview the parent scrolls up and down and if the touch was horizontal or a click then the

Is there any difference between `ListView.invalidateViews()` and 'Adapter.notifyDataSetChanged()'?

拈花ヽ惹草 提交于 2019-12-17 10:41:03
问题 Is there any difference between ListView.invalidateViews() and Adapter.notifyDataSetChanged() ? 回答1: Well yes, there is. ListView.invalidateViews() is used to tell the ListView to invalidate all its child item views (redraw them). Note that there not need to be an equal number of views than items. That's because a ListView recycles its item views and moves them around the screen in a smart way while you scroll. Adapter.notifyDataSetChanged() on the other hand, is to tell the observer of the