Android Question Custom View Standard Properties setting

Discussion in 'Android Questions' started by Cableguy, May 3, 2015.

  1. Cableguy

    Cableguy Expert Licensed User

    Hi guys...

    I'm creating a simple custom view with designer support. Since the base panel is not accessible from outside the "createview" sub, I initialized a secondary BasePanel and set it to be the Base, so it can be accessible by other subs, like a setLeft and getLeft sub...
    But I get an error when trying to set BasePanel, or any other of my customview views...
    I think its because the layout file is not yet finished loading/creating the views so they are not yet inilialized...
    So, my question is... how to implement basic props like Left, Top, Width and Height for a custom view WITH designer support so that thay can be accessible...?
  2. klaus

    klaus Expert Licensed User

    I use class private variables for this purpose.
    In the DesignerCreateView routine set the variables with the Base properties and then you can do what ever you want with them.
    Cableguy likes this.
  3. Cableguy

    Cableguy Expert Licensed User

    That I understand... but I keep getting "Panel should first be initialized" errors... even if I change for another view.. like a button, I get the errors relating to the buttons.inilializing

    [EDIT] I was making a very common mistake... I was re-initializing a view that was added in the designer... now it works!
    Last edited: May 3, 2015
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice