Wenn ich dieses Programm ausführen, es immer wieder sagen, dass "nicht lösen können, setOnClickListener" .animal bitte helfen Sie mir, dieses Problem zu lösen.kann nicht lösen Symbol SetOnClickListener in Android
import android.support.v7.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the content of the activity to use the activity_main.xml layout file
setContentView(R.layout.activity_main);
}
// Find the View that shows the numbers category
TextView numbers = (TextView) findViewById(R.id.numbers);
// Set a click listener on that View
numbers.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the numbers View is clicked on.
@Override
public void onClick(View view) {
Intent numbersIntent = new Intent(MainActivity.this, Numbers.class);
startActivity(numbersIntent);
}
}
}
verschieben Dein Code ins ide 'onCreate()'. – earthw0rmjim
Ja, oder implementieren Sie 'OnClickListener' und' numbers.setOnClickListener (this); ' – Amg91