walterf25 Expert Licensed User Longtime User Oct 29, 2018 #1 Hi all, i'm in the middle of wrapping a library used to do some UI Elements Inspection automation, one of the ways to look for elements in an apk file is by Resource-Id, does anyone know how are this names or IDs assigned to a layout, is there a way for us to manually assign this IDs ourselves, attached are some images i took using the UI Automation Viewer that comes with Android SDK, and while inspecting the views I can see that none of the views on the first screenshot have a Resource-Id name, but in the second screenshot on the AlertDialogBox you can see that there are some views which have a Resource-Id assigned to them. Is this a difference between an app created with B4A and Android Studio? Any thoughts?
Hi all, i'm in the middle of wrapping a library used to do some UI Elements Inspection automation, one of the ways to look for elements in an apk file is by Resource-Id, does anyone know how are this names or IDs assigned to a layout, is there a way for us to manually assign this IDs ourselves, attached are some images i took using the UI Automation Viewer that comes with Android SDK, and while inspecting the views I can see that none of the views on the first screenshot have a Resource-Id name, but in the second screenshot on the AlertDialogBox you can see that there are some views which have a Resource-Id assigned to them. Is this a difference between an app created with B4A and Android Studio? Any thoughts?
Semen Matusovskiy Well-Known Member Licensed User Oct 29, 2018 #2 You can set R.id in run time. For example Code: Copy Dim jo As JavaObject = EditText1 Dim id As Int = jo.RunMethod ("generateViewId", Null) jo.RunMethod ("setId", Array (id)) Log (jo.RunMethod ("getId", Null)) Upvote 0
You can set R.id in run time. For example Code: Copy Dim jo As JavaObject = EditText1 Dim id As Int = jo.RunMethod ("generateViewId", Null) jo.RunMethod ("setId", Array (id)) Log (jo.RunMethod ("getId", Null))
walterf25 Expert Licensed User Longtime User Oct 30, 2018 #3 Semen Matusovskiy said: You can set R.id in run time. For example Code: Copy Dim jo As JavaObject = EditText1 Dim id As Int = jo.RunMethod ("generateViewId", Null) jo.RunMethod ("setId", Array (id)) Log (jo.RunMethod ("getId", Null)) Click to expand... This is good to know, but i wonder why this is not implemented at the time of creating the views either in the designer as a property or programmatically when creating views, anyhow for the tool i'm wrapping the library for this would be a great thing to have as it would make things a lot easier. Regards, Walter Upvote 0
Semen Matusovskiy said: You can set R.id in run time. For example Code: Copy Dim jo As JavaObject = EditText1 Dim id As Int = jo.RunMethod ("generateViewId", Null) jo.RunMethod ("setId", Array (id)) Log (jo.RunMethod ("getId", Null)) Click to expand... This is good to know, but i wonder why this is not implemented at the time of creating the views either in the designer as a property or programmatically when creating views, anyhow for the tool i'm wrapping the library for this would be a great thing to have as it would make things a lot easier. Regards, Walter
Semen Matusovskiy Well-Known Member Licensed User Oct 30, 2018 #4 Guess, you can place this wish in https://www.b4x.com/android/forum/forums/bugs-wishlist.30/ Sure, it's not hard for B4A to integrate similar feature. But from another side ... Many persons do not use Visual Designer at all and to use names of fields is more simple than numeric id. Upvote 0
Guess, you can place this wish in https://www.b4x.com/android/forum/forums/bugs-wishlist.30/ Sure, it's not hard for B4A to integrate similar feature. But from another side ... Many persons do not use Visual Designer at all and to use names of fields is more simple than numeric id.
walterf25 Expert Licensed User Longtime User Oct 30, 2018 #5 Semen Matusovskiy said: Guess, you can place this wish in https://www.b4x.com/android/forum/forums/bugs-wishlist.30/ Sure, it's not hard for B4A to integrate similar feature. But from another side ... Many persons do not use Visual Designer at all and to use names of fields is more simple than numeric id. Click to expand... from what I understand the Resource-Id i'm referring to is a regular text name that is given to each view, if you look at the images i posted in the first post you can see on the second screenshot that the Resource-Id for the dialogbox title is a string and not a numeric id. Regards, Walter Upvote 0
Semen Matusovskiy said: Guess, you can place this wish in https://www.b4x.com/android/forum/forums/bugs-wishlist.30/ Sure, it's not hard for B4A to integrate similar feature. But from another side ... Many persons do not use Visual Designer at all and to use names of fields is more simple than numeric id. Click to expand... from what I understand the Resource-Id i'm referring to is a regular text name that is given to each view, if you look at the images i posted in the first post you can see on the second screenshot that the Resource-Id for the dialogbox title is a string and not a numeric id. Regards, Walter
DonManfred Expert Licensed User Longtime User Oct 30, 2018 #6 walterf25 said: second screenshot that the Resource-Id for the dialogbox title is a string and not a numeric id Click to expand... no, it is not an String. the id is a numeric value In this case the numeric value is pointing to a Resource. Here the resource is a String. But the reference to it is a Integer Upvote 0
walterf25 said: second screenshot that the Resource-Id for the dialogbox title is a string and not a numeric id Click to expand... no, it is not an String. the id is a numeric value In this case the numeric value is pointing to a Resource. Here the resource is a String. But the reference to it is a Integer
walterf25 Expert Licensed User Longtime User Nov 1, 2018 #7 Semen Matusovskiy said: You can set R.id in run time. For example Code: Copy Dim jo As JavaObject = EditText1 Dim id As Int = jo.RunMethod ("generateViewId", Null) jo.RunMethod ("setId", Array (id)) Log (jo.RunMethod ("getId", Null)) Click to expand... So I tried this and while it works and sets the Resource Id, i still don't see it when I inspect the views with UIAutomatorViewer, it must be a B4A thing that does not let the Resource Id be set. Walter Upvote 0
Semen Matusovskiy said: You can set R.id in run time. For example Code: Copy Dim jo As JavaObject = EditText1 Dim id As Int = jo.RunMethod ("generateViewId", Null) jo.RunMethod ("setId", Array (id)) Log (jo.RunMethod ("getId", Null)) Click to expand... So I tried this and while it works and sets the Resource Id, i still don't see it when I inspect the views with UIAutomatorViewer, it must be a B4A thing that does not let the Resource Id be set. Walter