so I'm trying to add OnClickListeners to dynamically created textviews inside of a horizontal scroll. I currently have dynamically created textviews, but of course, the manner I am setting the OnClickListener results in any click of one of the TextViews to send only the information of the last TextView which was created. For instance, I have 1000 textviews and all 1000 of them on click will give me the data of the 1000th textView. I'd like to pull the .text.toString() of whichever was clicked in order to send that data elsewhere. Here's what I've got:
protected void onPostExecute(JSONArray jArr) {
try {
for (int i = 0; i < jArr.length(); i++) {
flightList.add(jArr.getString(i));
aText = new TextView(getApplicationContext());
aText.setText(jArr.getString(i));
aText.setWidth(50);
aText.setBackgroundColor(Color.BLACK);
aText.setTextColor(Color.WHITE);
aText.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
GetMillis myTimer = new GetMillis();
aURL = "http://somelink?startTs="
+ myTimer.getThreeAMToday()
+ "&endTs="
+ myTimer.getFourAMTomorrow()
+ "&datafield="
+ aText.getText().toString();
new myScheduleTask().execute();
}
});
Any Help is appreciated!