I’ve a custom ListView containing 4 TextViews. Now, the TextViews have to be Linkifiable. Since Linkify wasn’t working in ListView, I made a callIntent function to see if the link is clickable or not. But if there’s no clickable link, I want to start a new Activity. I use the following code:
lvMembersList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
final TextView txtLine1 = (TextView) arg1.findViewById(R.id.tv_member_details_line1);
final TextView txtLine2 = (TextView) arg1.findViewById(R.id.tv_member_details_line2);
final TextView txtLine3 = (TextView) arg1.findViewById(R.id.tv_member_details_line3);
final TextView txtLine4 = (TextView) arg1.findViewById(R.id.tv_member_details_line4);
txtLine1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
callIntent(1);
}
});
txtLine2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
callIntent(2);
}
});
txtLine3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
callIntent(3);
}
});
txtLine4.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
callIntent(4);
}
});
}}
Now, when I click on an item for the first time, the TextView listeners are getting set. The individual clicks only works after the second time. What should I do in such a case?