android-listview

Use custom selector for parent item and children items in ExpandableListView

扶醉桌前 提交于 2019-12-06 07:47:14
I have expandable list which looks like this: Orange items are children and are shown when you press specific parent. Blue items are parents.I used this custom adapter to create this: (I picked this source code somewhere here on forum) public class ExpandableListAdapter extends BaseExpandableListAdapter { private Context context; private List<String> listDataHeader; private HashMap<String, List<String>> listDataChild; public ExpandableListAdapter(Context context, List<String> listDataHeader, HashMap<String, List<String>> listChildData) { this.context = context; this.listDataHeader =

setOnItemClickListener for ListView in a fragment

泪湿孤枕 提交于 2019-12-06 07:40:58
问题 I'm having problems clicking on ListView items in the fragments. I wrote the code so the fragments point to layout files for everything and inside the 2 of the layouts are ListViews, which retrieve their entries from items in a string array in the strings.xml. I could not find a way to implement a setOnItemClickListener for each ListView item in my case due to the way I wrote the code. MainActivity.java package com.example.test_app; import android.os.Bundle; import android.support.v4.app

Limit a listview to 25 items

血红的双手。 提交于 2019-12-06 07:33:35
I am displaying a listview programmiclly using the following codes: Below is how the listview is displayed programmatically: messagesList = (ListView) findViewById(R.id.listMessages); messageAdapter = new MessageAdapter(this); I would want to limit the list to 25 items, and where it is not infinite. Below is the layout. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/white_wallpaper" > <ListView android:id="@+id

How do I update ListView in another Fragment?

佐手、 提交于 2019-12-06 07:03:25
问题 I have an Activity which holds a ViewPager with 2 Fragments. One fragment is for adding items to ListView and another fragment is holding the ListView . I've been trying for almost 3 days now without any positive results. How do I update the other fragment's ListView from the first fragment? I'm trying to call the method that updates ListView from the Activity that holds ViewPager but it doesn't work. Calling the method from ViewPager activity : @Override public void onPageSelected(int

RelativeLayout as listview item

隐身守侯 提交于 2019-12-06 06:47:14
问题 Consider following RelativeLayout as list view item: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/bigfoo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:text="bigfoo" android:textSize="60sp"/> <TextView android:id="@+id

How to make divider part of each item in listview in android?

痴心易碎 提交于 2019-12-06 06:45:22
问题 I wanted to change the divider height dynamically. From whatever I have searched it seems that it is possible through setting divider as part of each item in ListView . But I am not very clear with this. So, can someone be more specific as how can one make the divider as part of item in ListView ? 回答1: A way to do this would be to include the divider at the bottom of each row. Now you have to set the height of the divider view in your getView method in your listadapter depending of the item

Android layout padding is ignored by dropdown

一笑奈何 提交于 2019-12-06 06:45:14
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:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true"

Android - How can diplay pictures in a simpleApapter list view

筅森魡賤 提交于 2019-12-06 05:50:36
I'm trying to display te pictures in a SimpleAdapter listview. I included Picasso in my project but i don't know how to use Picasso with a SimpleAdapter. List<HashMap<String, String>> featured = new ArrayList<HashMap<String, String>>(); for (int i=0;i<ids.length;i++){ HashMap<String, String> hm = new HashMap<String, String>(); hm.put("productname", names[i]); hm.put("productprice", prices[i]); hm.put("productimage", images[i]); featured.add(hm); } String[] from = {"productname", "productprice", "productimage"}; int[] to = {R.id.tv_ProductName, R.id.tv_ProductPrice, R.id.icon}; SimpleAdapter

How to combine an imageview with some text in listview

大兔子大兔子 提交于 2019-12-06 05:28:07
So far I've been using a simple ArrayAdapter to display some items in a ListView . Now I also want to display images alongside the text in the ListView . I have an AsyncTask called DownloadImageTask to download images. The downloading is working perfectly, but I don't know how to display an image in the ListView and how to use the DownloadImageTask to download the images in the ListView . This is the DownloadImageTask I use to download images into an ImageView : private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> { ImageView bmImage; public DownloadImageTask(ImageView

How to update the ListView of a Fragment from another Fragment?

喜欢而已 提交于 2019-12-06 05:15:10
问题 How can I communicate a listview of a ListFragment after an event of a Fragment inside another Fragment ? In the ListFragment (fragment A) I have a method to refresh the ListView . But also, I need to refresh it after a click of a Button inside a Fragment , wich is child of another Fragment (fragment b) Its like Fragment A (listFragment) | Fragment B (detailview) (fragment C - child fragment of B) How can I do it? 回答1: You can access another Fragment by its tag : // find your fragment