Reputation: 878
I have 3 TextView objects, that I created programmatically
Every TextView was repeated 7 times and ontouchlistener for the layer that contain them.
When onTouch on the layer, I want to gettext from one of the TextView by the same view Id
I already tried ..
//tvDay is the one i want to get it text
tvDay.findViewById(v.getId());
String course = tvDay.getText().toString();
Upvotes: 1
Views: 3603
Reputation: 1213
You should set onTouchListeners for your TextViews and not for the container.
Upvotes: 0
Reputation: 6383
The first parameter from the onTouch(View v, MotionEvent event)
method should be your containing layer.
From this view you should be able to call findViewById()
and pass the id of the TextView that you created. Just like in Sherifs comment:
tvDay = findViewById(v.getId());
Just another note (from what I know):
When you created the TextView
s programmatically you have to set an id
for the each single TextView
yourself (to be able to reference them in the findViewById()
method).
Upvotes: 1