I am adding a small view to a linearlayout. I have to apply a View.OnClickListener to it, but even though the view has been added, the onClick still does not fire. Here’s my method
for (Streams stream : streamArray) {
streamCount++;
if (!(streamCount > 3)) {
// ADD AN ITEM
View v = li.inflate(R.layout.stream_item, theLinearLayoutforStreamItems, false);
//SET ONCLICK
v.setOnClickListener(new android.view.View.OnClickListener() {
public void onClick(View v) {
Log.i("onclick", ""+position );
}
});
txtStreamItem = (TextView) v.findViewById(R.id.txtViewStream_item);
txtStreamItem.setText(stream.name);
theLinearLayoutforStreamItems.addView(v);
}
The onClick()does not fire. I do not know why, and I cannot find any thing on the internet on it.
I think what you really want to achieve is:
Put it just below this line: