I am trying to put a lens icon within an Edittext to indicate that it is a search box (as in the above screenshot). The following discussion at Stack Overflow mentions a solution. Any idea how to implement it in B4A, using Reflection library or some other way?
The required method setCompoundDrawablesRelativeWithIntrinsicBounds is available from TextView and is inherited by EditText from there.
Spinner is not a subclass of TexView and does not inherit the method.
The methods that are available are documented in the links above and most should be straightforward to implement via reflection if not already provided in B4A
I recently made a suggestion/wish for this very thing because I use it in my TabBar library and it works great. Using a 9 patch for a spinner though may be a better option. I also have a custom spinner/combobox in my LineLayout library that is a Label/Textview and should work with that method too. I may eventually add it to one of my libraries in the future, but really hope Erel adds it too.
You can use standard images, they just need to be passed as BitMapDrawables:
B4X:
Dim Bmp As Bitmap
Dim Bmpd As BitmapDrawable
Bmp.Initialize(File.DirAssets,"img.png")
Bmpd.Initialize(Bmp)
'Add to edittext1
ST="android.graphics.drawable.Drawable"
Dim R As Reflector
R.Target=EditText1
R.RunMethod4("setCompoundDrawablesWithIntrinsicBounds",Array As Object(Bmpd,Null,Null,Null),Array As String(ST,ST,ST,ST))