I have a cusom view derived from TableLayout, and I need to declare String property Title, like this:
<com.mycompany.controls.NavigationControllerView xmlns:app="http://schemas.usetech.com/apk/res/onroad" title="@string/nav_title" ... /> (to be able specify value via resource reference). I've specified this property in values/attrs.xml:
<declare-styleable name="NavigationControllerView"> <attr name="title" format="string"/> ... </declare-styleable> In my code I'm trying:
public class NavigationControllerView extends TableLayout { public NavigationControllerView(Context context, AttributeSet attrs) { super(context, attrs); View.inflate(getContext(), R.layout.inc_header, this); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NavigationControllerView); CharSequence title = a.getString(R.styleable.NavigationControllerView_title); if (title != null) setTitle(title.toString()); } ... but no luck, title is always null. Do you see where I'm wrong?