How To Get The Name Of Textview Included In Linear Layout In Onclicklistener?
I am adding textviews dynamically to a linear layout and want to get the name of the textview clicked in OnClickListener of linear layout.This is the code: m_lvSideIndex = (LinearL
Solution 1:
You can do with it the help of getTag()
first setTag() the value i.e TextName
m_lvSideIndex.setTag(m_arrayOfAlphabets[l_a]);
m_lvSideIndex.setTag(l_a, R.id.sideIndex);
and get the value via getTag()
m_lvSideIndex.setOnClickListener(newOnClickListener()
{
@OverridepublicvoidonClick(View v)
{
String l_itemSelected = (String)v.getTag();
Integer l_position = (Integer)v.getTag(R.id.sideIndex);
});
Solution 2:
Add your click listener to each text view, you will then receive the view as parameter in onClick.
Solution 3:
OnClickListener works on TextView. Make sure you set Clickable property of TextView to true.
Solution 4:
((TextView)v.findviewbyTag(R.id.label)).getText();
I hope this work
Post a Comment for "How To Get The Name Of Textview Included In Linear Layout In Onclicklistener?"