android-listview

Android: Detect if a ListView has the scrollbar (after setting new data)

天大地大妈咪最大 提交于 2020-01-14 10:42:50
问题 I have an ArrayAdapter linked to a ListView. mListView.setAdapter(mArrayAdapter); Whenever I reset the ArrayList data to the ArrayAdapter: mArrayAdapter.clear(); mArrayAdapter.addAll(mArrayList); mArrayAdapter.notifyDataSetChanged() the ListView gets correctly updated however, if just after the above three lines, I call my custom method mListView.hasScrollbar() to detect whether the listview has a scrollbar or not, I get a null lastVisibleItem : public boolean hasScrollbar() { View

How to use SparseArray as a source for Adapter?

此生再无相见时 提交于 2020-01-14 09:35:08
问题 I have a sparse array of values which I want to populate in a Spinner, and when the item is selected, I want to get the id (which is the key from the sparse array). What is the preferred way of creating an adapter from a SparseArray? Is it possible to subclass an existing Adapter like BaseAdapter or ListAdapter So that the items will have a key from the SparseArray as item id? Not knowing how to achieve the above, I am thinking of creating a simple ArrayAdapter instance and giving it values

The clear() in custom listview adapter also updates the list data

六眼飞鱼酱① 提交于 2020-01-14 06:35:30
问题 I am working on a listview filter, that means, there is a editbox, if I type in some keywords , the listview data will change accordingly. To begin with, there is a dataset. private ArrayList<PostItem> postList; Assuming the list is already fill with data, here is the adapter with filtering: private class PostAdapter extends ArrayAdapter<PostItem> implements Filterable { public PostAdapter(Context context, int resource, List<PostItem> items) { super(context, resource, items); } @Override

Get the position of Button in List View

瘦欲@ 提交于 2020-01-14 05:36:07
问题 I have one problem. I want to get the position of Button in List View . In below image when I clicked in Edit or Delete button i just want its position in List View . How it possible? This is my Office Management Screen. All the data getting in ListView run-time from my web-service. I get the data in List View by using this code- ListAdapter adapter = new SimpleAdapter(Office_Mgmt.this, officeList, R.layout.office_mgmt_list_model, new String[] { "office_name" }, new int[] { R.id.label});

Android: Not sure why my listview is getting all jumbled up?

一曲冷凌霜 提交于 2020-01-14 03:23:22
问题 I implemented a ListView that worked correctly until I added more than 5 items and 2 headers. Im not entirely sure why some items are not appearing and others are appearing multiple times. Any assistance in fixing this will be much appreciated. Code is include below. Toolbox.java public class Toolbox extends Fragment { private ListView lstView; private View rootView; List<Tools> tools; public static Toolbox newInstance(Context context) { Toolbox fragment = new Toolbox(); return fragment; }

How to retrieve and display browser history and bookmarks in browser application [duplicate]

微笑、不失礼 提交于 2020-01-14 03:11:07
问题 This question already has answers here : Get browser history and search result in android (2 answers) Closed 5 years ago . Hi friends i am new to android I don't know how to retrieve and display history in web browser. Please guide me and share your thoughts, ideas and bookmarks too. I have to display history in ListView 回答1: ArrayList mTitles=new ArrayList(); ArrayList mUrls=new ArrayList(); public void getBrowserHist() { Cursor mCur = managedQuery(Browser.BOOKMARKS_URI, Browser.HISTORY

Android layout padding is ignored by dropdown

前提是你 提交于 2020-01-13 19:44:28
问题 As xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="20dp"> <Button android:id="@+id/locationButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:minWidth="46dip" android:onClick="getLocation" android:text="@string/icon_map_marker" /> <AutoCompleteTextView android:id="@+id/autocomplete_city" android

OnItemCLickListener not working in ListView custom adapter

≯℡__Kan透↙ 提交于 2020-01-13 05:55:08
问题 I have two activities. One displays all the products in a ListView . Second activity runs when an item is selected. Basically second activity should fire up on item click and it should open the PDF file. Well the thing is that it does not fire up 2nd activity on item select. Posting the code for your reference. My .xml file <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height=

Is ListView completely inferior to RecyclerView?

五迷三道 提交于 2020-01-12 18:34:09
问题 So, Vogella seems to suggest that ListView is completely being deprecated in comparison with RecyclerView. And not actually deprecated, but rather that there is no situation in which ListView would be a better choice. Is this true? The commonsware book suggests that it might be faster at updating. Is there any other reason to completely avoid ListView from now on? Just reading through some examples, it seems that RecyclerView adds many layers of difficulty/convolution to the code, hence my

How to get listview height in android?

99封情书 提交于 2020-01-12 14:07:51
问题 I need to find the height of android ListView with custom ListVAdapter. Each of ListView items can be of varying height. I have tried the following code which I found here: public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, MeasureSpec