Possible Duplicate:
How to read custom attributes in Android
Recently I read about custom attributes. I want to add a custom attribute to TextView.
So far I have:
attr file:
<resources>
<attr name="binding" format="string" />
<declare-styleable name="TextView">
<attr name="binding" />
</declare-styleable>
layout file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:custom="http://schemas.android.com/apk/res/de.innosoft.android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
custom:binding="test"/>
Given a TextView
TextView tv = ...
How would I then get the value of that attribute (which ist "test")? I read about obtainStyledAttributes but do not know exactly how to use it here.