hi,
I have real difficulty in achieving a Listview with rounded corners using an XML file.
Following the excellent tutorials of Erel (Fig. 9-patch) of Informatix (but how do they) warwound (xml file) and Klaus (Reflector), I said "bingo" to you lol
I found on the stackoverflow's site the "roundedcorner.xml" file that does this and to get into my package I have to run java "ListView (R.drawable.roundedcorner)."
But now, from theory to practice ..... I'm still missing a few links .... or a few tips for the do-it-yourself enthusiast... Thank you
My environment : Galaxy note 2 - B4a v1.50 and android api-16 - Reflector v2.10
File roundedcorner.xml
this xml file, attributes in "read only", is placed in my directory ..../objects/res/drawable
in apk, the file roundedcorner.xml is located in res/drawable
Extract :
an error is occured id = r.GetStaticField( ..... :
..... java.lang.NoSuchFieldException: roundedcorner
Thank you for your help
I have real difficulty in achieving a Listview with rounded corners using an XML file.
Following the excellent tutorials of Erel (Fig. 9-patch) of Informatix (but how do they) warwound (xml file) and Klaus (Reflector), I said "bingo" to you lol
I found on the stackoverflow's site the "roundedcorner.xml" file that does this and to get into my package I have to run java "ListView (R.drawable.roundedcorner)."
But now, from theory to practice ..... I'm still missing a few links .... or a few tips for the do-it-yourself enthusiast... Thank you
My environment : Galaxy note 2 - B4a v1.50 and android api-16 - Reflector v2.10
File roundedcorner.xml
B4X:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90"
android:endColor="#C0C0C0"
android:startColor="#808080" />
<corners
android:bottomLeftRadius="7dp"
android:bottomRightRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
<stroke
android:width="1px"
android:color="#000000" />
</shape>
this xml file, attributes in "read only", is placed in my directory ..../objects/res/drawable
in apk, the file roundedcorner.xml is located in res/drawable
Extract :
B4X:
'Activity module
Sub Process_Globals
End Sub
Sub Globals
Dim p1, p2 As Panel
Dim ListView1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Glossaire")
AfficheGlossaire
End Sub
Sub AfficheGlossaire
...
p1.Initialize("p1")
Activity.AddView (p1, 0, 0, Activity.Width, Activity.Height)
...
ListView1.Initialize("ListView1")
p1.AddView(ListView1, 5%x, 95dip, 90%x, 80%y)
...
' To create a listview with rounded corners create a shape in xml
' Create roundedcorner.xml in the res/drawable
SetDrawable(ListView1, "roundedcorner")
End Sub
Sub SetDrawable(Control As ListView, XMLName As String)
'*** In java set your listview : ListView.(R.drawable.roundedcorner);
Dim r As Reflector
Dim package As String
Dim id As Int
package = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
id = r.GetStaticField(package & ".R$drawable", XMLName)
r.Target = r.GetContext
r.Target = r.RunMethod("getResources")
Control.Background = r.RunMethod2("getDrawable", id, "java.lang.int")
End Sub
an error is occured id = r.GetStaticField( ..... :
..... java.lang.NoSuchFieldException: roundedcorner
Thank you for your help
Last edited: