android-listview

ArrayAdapter and ListView - ArrayIndexOutOfBoundsException

夙愿已清 提交于 2019-12-04 07:46:08
I'm really hoping someone can help me out with this one. I've been stuck on it forever. Occasionally, when someone is using my app, it'll force close with this exception: java.lang.ArrayIndexOutOfBoundsException at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:3572) at android.widget.AbsListView.trackMotionScroll(AbsListView.java:2487) at android.widget.AbsListView.onTouchEvent(AbsListView.java:2001) at android.widget.ListView.onTouchEvent(ListView.java:3234) at android.view.View.dispatchTouchEvent(View.java:3709) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup

ListView with longClick for showing and hiding Checkbox?

守給你的承諾、 提交于 2019-12-04 07:37:17
I read along the code here (weblink). And the code has been modified a little bit to become like this: FileArrayAdapter.java public class FileArrayAdapter extends ArrayAdapter<Item> { private Context c; private int id; private List<Item> items; public FileArrayAdapter(Context context, int textViewResourceId, List<Item> objects) { super(context, textViewResourceId, objects); c = context; id = textViewResourceId; items = objects; } public Item getItem(int i) { return items.get(i); } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v ==

keeping bottom element of ListView visible when keyboard appears

一个人想着一个人 提交于 2019-12-04 07:34:57
I have a LinearLayout containing both a ListView and an EditText . When the On-Screen keyboard is launched by touching the EditText , the ListView resizes so that only the top few elements remain visible. The context that the ListView is being used in has the bottom few elements being more visually relevant than the top, and so I'd like for it to resize so that the bottom remains visible, rather than the top. Any pointers? (Incidentally, the current fix I'm using involves using smoothScrollToPosition , but the laggy scroll behaviour makes this undesirable) I just solved a similar issue this

ListView in ScrollView - small bug

筅森魡賤 提交于 2019-12-04 07:25:43
问题 I'd like to have a listview in scrollview. This method is doing it almost perfect: https://stackoverflow.com/a/3495908/2811653 There is a bug when I enter more text in a row than fits in one line: 1: http://abload.de/img/screenshot_2013-10-311jq5t.jpg 2: http://abload.de/img/screenshot_2013-10-31lvrad.jpg Scrolling down to the button works fine BUT as you see in the second screenshot the P is not displayed correctly :-( In the Utility class the height is not calculated correctly when I fill

Android - Getting database ID from ListView selection

自古美人都是妖i 提交于 2019-12-04 07:11:13
问题 I have a ListView lv which uses a Cursor c from an SQL database to populate it. When an item is selected however, I need to get the ID of the row. How can I do this? 回答1: I assume that you are using a SimpleCursorAdapter (or similar), so I would use the OnItemClickListener: listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // id references the SQLiteDatabase _id column } }); 回答2: Here's how

Hide custom search bar if all items in adapter are showing

混江龙づ霸主 提交于 2019-12-04 07:09:46
问题 The problem I have is that listView.getLastVisiblePosition always returns -1 so I can't hide the searchView . I check this right after setting the adapter and anywhere I have tried to put this it still returns -1. I didn't see in the Docs why this would be but I imagine it would return -1 if the ListView is not showing any items. However, listView.getFirstVisiblePosition() returns 0 always, even when there is more than one item showing. I have tried both methods Here but it doesn't make a

Dynamically generated Radio button changes its position while scrolling

我的梦境 提交于 2019-12-04 07:00:05
问题 I have created dynamically Radio Buttons .And they are displayed quite well, but when I select and scroll it loses its position. I know the way of setting and getting the tag with ViewHolder class and convert view . but this time, I have dynamic ids, so I cant tag id . i have tried like this converview.setTag(rdbtn.getId(),rdbtn); But it throws The key must be an application specific Resource id . Here is my Custom Adapter Class static class FeedBacksubmitionViewHolder { protected TextView

android listview intent

泪湿孤枕 提交于 2019-12-04 06:52:59
问题 I am not able to create an intent after click in my Listview. After completing It gives an error The application has stopped unexpectedly, please try again public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent IntentDiscution = new Intent(view.getContext(), lstchoi.class); IntentDiscution.setClass(InterfaceAcceuil.this, lstchoi.class); startActivityForResult(IntentDiscution, 0); } 回答1: Make sure you declared lstchoi in your manifest.xml. Assuming it is an

ListView.hasWindowFocus==true but child views hasWindowFocus==false

。_饼干妹妹 提交于 2019-12-04 06:30:04
问题 Sometimes I notice that, for a View v - v.hasWindowFocus()==false - ((View)v.getParent()).hasWindowFocus())==true If I understand the docs correctly, this should never be the case. v.getParent() is a (subclass) of ListView Any ideas on what might be causing this? Note: I assume this hasWindowFocus-mismatch is the root cause for this issue 回答1: The main reason is that ListView doesn't like an adapter having an array of views. So the problem is triggered by code like public View getView (int

Can not reload ListView Content after implementing Filterable interface on my CustomListAdapter

佐手、 提交于 2019-12-04 06:29:04
问题 I have two questions here. The First Question goes :: After i implementing Filterable interface in my CustomListAdapter to enable search on list data, i realized that each time i try to reload the listview, it refused to populate the listview even thought i was able to fetch the data from my server. (My ListView always reloads on device orientation change and i also added a reload button to reload the listView onclick too) The Second Question goes :: My search EditView populates my listView