Android Question Open spinner with code

ValhallSW

Member
Licensed User
Longtime User
I know this has been up earlier, but it is a long time ago.

Is it possible to open a spinner without having to click on it.
 

DonManfred

Expert
Licensed User
Longtime User
Is it possible to open a spinner without having to click on it.
The forumsearch IS working ;-)

 
Upvote 0

ValhallSW

Member
Licensed User
Longtime User
May 13, 2011:
This is currently not possible.

Jan 17, 2012:
It is currently not possible.

May 13, 2020:
Dim policy As JavaObject
Try
policy = SpinConductorOAcompanante
policy = policy.RunMethodJO("performClick", Null)
Catch
Log(LastException)
End Try

Just without the try!

I'm sorry for not being a Java-Wiz or whatever. But I don't know what to do with that code. Nothing there tells me which spinner to open. The other links does not tell me anything either. I'm using B4A because I didn't want to learn other languages to make apps.

I was hoping for an answer here from someone that could help. Not gettting moched for not being able to search, which I actually tried. Thank you DonManfred!
Can I assume from your answer that it is not possible in B4A, whithout external stuff?

If it is not possible, why didn't you just say so?
I just hoped that the language had changed more since 2012. Of course it did. I know!!! But I have never had this problem before. Sorry for that comment, Erel. I love B4A.

I should of course included all results from my search in the opening post . I'm sorry for not doing so.
 
Last edited:
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
i had to do it this way:

in your b4a (assuming you want to open spinner1):
B4X:
dim jo as javaobject
jo.RunMethod("openSpinner",Array(spinner1.As(JavaObject)))

then tack this on to the end of your project:
Java:
#if Java
import android.widget.Spinner;
import java.lang.reflect.Method;

public void openSpinner(Spinner spinner) {
    try {
        Method method = Spinner.class.getDeclaredMethod("performClick");
        method.setAccessible(true);
        method.invoke(spinner);
    } catch (Exception e) {
        BA.Log(e.toString());
    }
}
#End If
 
Last edited:
Upvote 0
Top