So I'm trying to get the user to be able to set an onClickListener on a button which will change a TextView upon clicking. However, this causes a final declaration error to appear because I am calling it from an inner class. I don't understand why it requires it to be set to a final, unchangeable variable. I just want the Textview to accept the setText method on an onclick, but when using fragments it prevents me from doing so.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_main, container, false);
View v2 = inflater.inflate(R.layout.flash_fragment, container, false);
Button reply = (Button) v2.findViewById(R.id.replyB);
TextView flashtext = (TextView) v2.findViewById(R.id.flashtext);
flashtext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//start playing the string word by word
//on the textview : flashtext
***flashtext.setText("test");***
}
});