I know how to create a custom style attribute definition and get the value in a custom view (from this link):
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyCustomView, defStyle, 0);
String str = a.getString(R.styleable.MyCustomView_my_custom_attribute);
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
whatever:custom_global_tag="key" />
MyStaticClass.Process(View view, String key) {}
Try Theme?
A theme is a style applied to an entire Activity or application, rather than an individual View (as in the example above). When a style is applied as a theme, every View in the Activity or application will apply each style property that it supports.
Note: just work for property the view supports.
Edit #1
if you want to pass a different string on each view, just use android:tag
something like:
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="key" />
and get the string
String key = textView.getTag();
Edit #2
set a tag to identify which view you want.
in the activity, iterate all the views to find the identified view like
final ViewGroup viewGroup = (ViewGroup)((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
for(int i = 0; i < viewGroup.getChildCount(); i++) {
View childView = viewGroup.getChildAt(i);
if ("identificaton".equals(childView.getTag())) {
// do some work to child view.
}
}
the viewGroup part can check the post