Reputation: 5170
I am having a dynamic table in which I have created lots of textview
dynamically... actually I having one row in which I have 3 textview
... in this one of them contains unique id but other's textview
value repeats around the table... therefore on the click of other textview
I need text from unique textview
.... so please suggest some thing like getting text from the neighbor textview
... line through which I am able to get text from the textview
is following.
((TextView)v).getText().toString();
Upvotes: 2
Views: 6905
Reputation: 11765
When creating dynamic TextViews
assign a reference to the unique TextView
as a tag using setTag
to each of them.
TextView uniqueTextView = (TextView)findViewById(R.id.unique_id);
TextView neighbourView = new TextView();
neighbourView.setTag(uniqueTextView);
You can later get the reference back using getTag
public void onTextViewClick(TextView view) {
TextView uniqueTextView = (TextView)view.getTag();
String text = uniqueTextView.getText().toString();
}
Upvotes: 2