android-listview

Navigation Drawer with Headers/Sections

拥有回忆 提交于 2019-12-03 06:10:41
问题 I would like to know if there is any way that I can add headers/sections to the navigation drawer. I managed to add something like that, but it is only displayed at the top of the list, because addHeaderView needs to be called before setAdapter and if I try to add more elements after setAdapter they will rewrite the first elements. Thanks. Edit: public class MenuListAdapter extends BaseAdapter { // Declare Variables Context context; String[] mTitle; String[] mSubTitle; int[] mIcon;

How to let OnClick in ListView's Adapter call Activity's function

纵然是瞬间 提交于 2019-12-03 05:56:39
I have an Android application with a ListView in it, the ListView will setup fine but now I want a image in the ListView to be clickable. I do this by using 2 classes, the Activity class (parent) and an ArrayAdapter to fill the list. In the ArrayAdapter I implement a OnClickListener for the image in the list that I want to be clickable. So far it all works. But now I want to run a function from the activity class when the onClick, for the image in the list, is run but I do not know how. Below are the 2 classes that I use. First the Activity class: public class parent_class extends Activity

List view set a custom ripple selector

南楼画角 提交于 2019-12-03 05:51:46
I'm trying to use a list view control on Lollipop under the following conditions: The theme type is the default Theme.Material (dark theme). The list view is contained inside of larger layout which has a white background. The list view should have a list selector that appears with the white background. NOTE: I am forced to use a custom list selector color because if I use a white background, the dark material themed selector uses the theme's colorControlHighlight color for the ripple, which is 40ffffff, and does not show up. I first tried the following: layout xml <LinearLayout android:layout

Retaining list in list fragment on orientation change

时间秒杀一切 提交于 2019-12-03 05:50:56
问题 I have an app using fragments, all of which are contained in a single activity. The activity starts with a fragment containing a menu of buttons, all of which cause various listfragments to replace the original button/menu fragment. My problem is that upon an orientation change, if the activity is displaying one of the listviews, it goes away and the button menu returns. I understand why this is happening... the activity is destroyed and re-created, but not how to work around it and maintain

Advantage of ListFragment over a ListView or normal Fragment

≯℡__Kan透↙ 提交于 2019-12-03 05:40:07
问题 I have an activity with a menu of items running down the left side that are textViews. when the user selects one of the textViews it will put a listView in the rest of the area of the activity taking up the other 2\3 of the screen. when the user touches a different textView on that left side menu of the page, it will open a different corresponding listView of items. i was considering putting a large listview on the screen for this purpose. however one other way is instead of using a regular

Animate selector/state transitions

穿精又带淫゛_ 提交于 2019-12-03 05:30:19
问题 I have a simple selector for my ListView <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/yellow_arc" android:state_activated="true"/> <item android:drawable="@drawable/yellow_nonarc" android:state_activated="false"/> </selector> I want to animate the transition between these drawables when the state of the views are changed from activated to not-activated and vica versa. If you run the example in

Ripple effect does not show up sometimes

拈花ヽ惹草 提交于 2019-12-03 05:16:54
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"/> </shape> </item> <item> <shape><solid android:color="@android:color/transparent"/> </shape> </item> <

How to select an ListView item after long click?

谁说我不能喝 提交于 2019-12-03 05:10:07
问题 I've got a silly little problem. I've registered a ListFragment both as OnItemClickListener and OnItemLongClickListener of its own ListView . When the onItemClick event is called, an intent for the detail view activity of that item is started, no problems there. When the onItemLongClick event happens, I want to accomplish the following things: Create a CAB Keep the long-pressed item selected Code: @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id

ListView is not showing correct values after scrolling

好久不见. 提交于 2019-12-03 04:56:07
In my application I am using a CustomListView with an ArrayAdapter to show different countries time. But after 6 to 7 rows(depending on the phone screen size) the time values are repeating. According to some previous post I have written the following code snippet to get the solution. But the problem is still there. Following is the code I have written: public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; Order o = items.get(position); if (v == null) { LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout ll

Adding items to ListView, maintaining scroll position and NOT seeing a scroll jump

随声附和 提交于 2019-12-03 04:41:18
问题 I'm building an interface similar to the Google Hangouts chat interface. New messages are added to the bottom of the list. Scrolling up to the top of the list will trigger a load of previous message history. When the history comes in from the network, those messages are added to the top of the list and should not trigger any kind of scroll from the position the user had stopped when the load was triggered. In other words, a "loading indicator" is shown at the top of the list: Which is then