“android.view.View is deprecated” - what else to u

2019-08-10 11:14发布

问题:

I have just started trying out Android Studio, following the instructions on a video tutorial.

Here is my take on what the guy tells me but I keep getting the error message View is deprecated.

How do I fix this? Or what do I use instead?

Here is my code:

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button sendButton0001 = (Button) findViewById(R.id.buttonSend0001);
    EditText welcomeText = (EditText) findViewById(R.id.editTextWelcome);
    sendButton0001.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });
}

回答1:

This is just a warning. I don't know why it shows up, but if it runs fine - don't take care.