I have a custom listView with and adapter:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
String player = playerList.get(position);
View vi = convertView;
String index = String.valueOf(position + 1);
if (convertView == null) {
holder = new ViewHolder();
vi = inflater.inflate(R.layout.new_player_view, null);
holder.text = (TextView) vi
.findViewById(R.id.txtV_player_input_position_title);
holder.edit = (Button) vi.findViewById(R.id.btn_Edit_Title);
holder.edit.setOnClickListener(this);
holder.text.setOnTouchListener(null);
holder.text.setText((index) + ". " + player);
vi.setOnTouchListener(null);
vi.setTag(holder);
} else {
holder = (ViewHolder) vi.getTag();
holder.text.setText((index) + ". " + player);
holder.edit.setOnClickListener(this);
}
return vi;
}
@Override
public void onClick(View v) {
TextView text = (TextView)v.getContext();
String s = text.getText().toString();
Intent intent = new Intent();
intent.setClass(context, PlayerActivity.class);
intent.putExtra("name", s);
context.startActivity(intent);
};
I am trying to get the text from the TextView that is in the custom ListView when I hit the edit button (also in textView). In my onClick - I want to take the text and pass it to an edit screen, so user can edit the text and return to the listview. My question is how do I get the text? I've tried static text and it works that way, but I can't figure out how to get the text from the TextView. Thanks!