Android:How to get the text from the Button when clicked? [duplicate]
问题 This question already has answers here : Get text from pressed button (6 answers) Closed 6 years ago . for( i=0; i<26; i++) { btnAlpha[i] = new Button(this); btnAlpha[i].setBackgroundColor(Color.TRANSPARENT); btnAlpha[i].setTextColor(Color.GREEN); btnAlpha[i].setText(Character.toString ((char)(j+i))); btnAlpha[i].setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ //Want to get the text from the current button. btnAlpha[i].getText(); //But it gives error that "i"