Behavior like tools:text in a custom view?

半世苍凉 提交于 2019-12-06 15:12:00

I am a dingus and lied to you all. isInEditMode() was not returning false.

cough cough:

    if (isInEditMode()) {
        key.setText(a.getText(R.styleable.MyCustomView_key_preview));
        value.setText(a.getText(R.styleable.MyCustomView_value_preview));
    } else {
        key.setText(a.getText(R.styleable.MyCustomView_key));
        value.setText(a.getText(R.styleable.MyCustomView_value));
    }

Turns out what I had initially was in fact setting the key to be the value of app:key_preview, however it was then subsequently overwritten with the null that a.getText(R.styleable.MyCustomView_key) was returning.

voopz.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!