Need help for extension

Hi how to get view object from one extension to another extension from hashmap. Is it possible ?

Here is an example from CustomWebView extension:

You will have to provide more information if you wish to get a detailed answer.

5 Likes

A HashMap is a variable, just like an int or a String. If you're storing your Views in a HashMap and want another extension to retrieve them, I think you have to compile the two extensions together, and do something like this.

ExtensionOne.java

public class ExtensionOne extends AndroidNonvisibleComponent {
    public HashMap<String, View> views = new HashMap<>();

    public ExtensionOne(ComponentContainer container){
        super(container.$form());
    }
}

ExtensionTwo.java

// You'll also have to import ExtensionOne

public class ExtensionTwo extends AndroidNonvisibleComponent {
    public ExtensionOne(ComponentContainer container){
        super(container.$form());
    }

    public View getView(String key, ExtensionOne extensionOne) {
        HashMap<String, View> viewsMap = extensionOne.views;
        return viewsMap.get(key);
    }
}

My code may contain errors as I didn't compile it.

5 Likes

i m trying to delete view from hashmap from this method i achived but not deleting view permanently

how to delete view permenently

 @SimpleFunction(description = "")
  public void DeleteView(String id) {
    ((ViewGroup) ((View) this.ViewContainer.get(id)).getParent()).removeView((View) this.ViewContainer.get(id));

    this.ViewContainer.remove(id);
  }

You are already removing view from screen, so I assume you meant to destroy view after removing it.
Well, Android does that for you. Removing it from view hierarchy is enough to tell Android to destroy it when required.

Ur right but when i refresh screen its still remain

What does it mean?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.