How do I create a ListView with rounded corners in Android?

Here is one way of doing it (Thanks to Android Documentation though!): Add the following into a file (say customshape.xml) and then place it in (res/drawable/customshape.xml) <?xml version=”1.0″ encoding=”UTF-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle”> <gradient android:startColor=”#SomeGradientBeginColor” android:endColor=”#SomeGradientEndColor” android:angle=”270″/> <corners android:bottomRightRadius=”7dp” android:bottomLeftRadius=”7dp” android:topLeftRadius=”7dp” android:topRightRadius=”7dp”/> </shape> Once you are done with creating this file, just set the background in … Read more

How can I parse a local JSON file from assets folder into a ListView?

As Faizan describes in their answer here: First of all read the Json File from your assests file using below code. and then you can simply read this string return by this function as public String loadJSONFromAsset() { String json = null; try { InputStream is = getActivity().getAssets().open(“yourfilename.json”); int size = is.available(); byte[] buffer = … Read more

How can I put a ListView into a ScrollView without it collapsing?

Here’s my solution. I’m fairly new to the Android platform, and I’m sure this is a bit hackish, especially in the part about calling .measure directly, and setting the LayoutParams.height property directly, but it works. All you have to do is call Utility.setListViewHeightBasedOnChildren(yourListView) and it will be resized to exactly accommodate the height of its … Read more

How to set space between listView Items in Android

@Asahi pretty much hit the nail on the head, but I just wanted to add a bit of XML for anyone maybe floating in here later via google: <ListView android:id=”@+id/MyListView” android:layout_height=”match_parent” android:layout_width=”match_parent” android:divider=”@android:color/transparent” android:dividerHeight=”10.0sp”/> For some reason, values such as “10”, “10.0”, and “10sp” all are rejected by Android for the dividerHeight value. It wants … Read more

How to change color of Android ListView separator line?

You can set this value in a layout xml file using android:divider=”#FF0000″. If you are changing the colour/drawable, you have to set/reset the height of the divider too. <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”wrap_content”> <ListView android:id=”@+id/android:list” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:divider=”#FFCC00″ android:dividerHeight=”4px”/> </LinearLayout>

Maintain/Save/Restore scroll position when returning to a ListView

Try this: // save index and top position int index = mList.getFirstVisiblePosition(); View v = mList.getChildAt(0); int top = (v == null) ? 0 : (v.getTop() – mList.getPaddingTop()); // … // restore index and position mList.setSelectionFromTop(index, top); Explanation: ListView.getFirstVisiblePosition() returns the top visible list item. But this item may be partially scrolled out of view, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)