Extend Homescreen widgets

XverhelstX

Well-Known Member
Licensed User
Longtime User
Hello everyone,

This question is actually asked to Erel about the homescreen widgets.

Is it possible for me to create a library that interacts with Basic4Android to extend the functions of homescreen widgets?

What i mean is that I still miss some functions like setLayout on runtime, etc., that I can make with a library.

Thanks,
XverhelstX

Sent from my SE Xperia Play using Tapatalk.
 

agraham

Expert
Licensed User
Longtime User
I think the last possibility would be with remoteviews.setInt: setPadding(int, int, int, int)
Nope. The invoked method can only accept a single int argument.
setInt - Call a method taking one int on a view in the layout for this RemoteViews
 
Upvote 0

XverhelstX

Well-Known Member
Licensed User
Longtime User
Ah darn.
I should have read that. :eek:

Anyway, I have another question, but I don't want to make a new thread as it's fairly a small question.

In java, how can I retrieve a views name using findViewByID?

B4X:
/**
    * Returns the views name.
    * @param view
    * @return
    */
   public string findViewByID (int id) {
      return ba.activity.findViewById(id).tostring;
      
   }

but this gives me a nullpointerexception.
I'd like to return the views name using findViewById, and note that this has nothing to do with the Widget library.

Thanks,

XverhelstX
 
Upvote 0

XverhelstX

Well-Known Member
Licensed User
Longtime User
I see. So they work with these so called identifiers.

why doesn't this work then?

B4X:
/**
    * Returns the viewID
    * @param view
    * @return
    */
   public int getId (View view) {
      return view.getId();
      
   }

/**
    * Returns the view's height
    * @param view
    * @return
    */
   public int getViewHeight (int id) {
      return ba.activity.findViewById(id).getHeight();
      
   }

The first code gives me 2,

but the second gives me a java.nullpointerexception.

So how can I get the views height then with the findViewByID?

Thanks,

Tomas
 
Upvote 0
Top