Q:

How to write onclick actions for dynamically generated textviews in android?

I have to display the textviews dynamically in android and need to write onclick action for each textview. I am able to display the textviews dynamically but I didnt get 
how to write the onclick action for each textview. Please help me regarding this...Will be thankful to you..

A:

Create the views dinamically however you want to do and add the listener right then.
TextView tv = new TextView(ActivityName.this);
tv.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
       Toast.makeText(ActivityName.this, "tv text: " + ((TextView) v).getText().toString()).show();
       //Do whatever you want to do here.
    }
});
layout.addView(tv); //layout added on the xml for example, or by an inflater.

