I am using a method in which json and php are used to dynamically get information to fill a table. here is an example
TextView team = new TextView(this);
team.setTextColor(Color.BLACK);
team.setPadding(3, 3, 0, 3);
team.setLayoutParams(new LayoutParams(80,
LayoutParams.WRAP_CONTENT));
team.setText(json_data.getString("team"));
team.setTag(json_data.getString("team"));
tr.addView(team);
How would I make it so each TextView is click-able and sends the Tag information to a new Activity? How do I initialize the TextView team?
team.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
//What goes in here???
}
});
My goal is for the user to be able to click on a team name and be sent to an activity where team information is given.
Any help is appreciated
team.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
//What goes in here???
String teamTag = (String)v.getTag();
Intent newIntent = new Intent(MyActivity.this, NewActivity.class);
newIntent.putExtra("teamName", teamTag);
startActivity(newIntent);
}
});
and in newActivity to read the tag, use this..
String teamTag = getIntent().getStringExtra("teamName");