So I would like to create a new TextView when a button is clicked. For some reason, TextView(this) doesn't work when it is inside of an onClick(). I would like to be able to do this with just java.
Again, when I create a TextView inside of onClick, there is an error when I make a TextView(this).
EditText name = layout.findViewById(R.id.enterName);
final String Name = name.getText().toString();
Button create = layout.findViewById(R.id.create);
create.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TextView textView = new TextView(this);
textView.setText(Name);
}
});
I get the error, "TextView (android.content.Context) in TextView cannot be applied to (anonymous android.view.View.OnClickListener)".