这是我的代码,假设在按下按钮时更改一些文本: –
public class MyActivity extends ActionBarActivity { TextView txtview; Button butto; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); ImageView imageView = (ImageView) findViewById(R.id.image); txtview = (TextView) findViewById(R.id.text); butto = (Button) findViewById(R.id.buttn); butto.setOnClickListener(new View.OnClickListener() { public void Onclick(View paramView) { txtview.setText("You Clicked it!"); } }); }}
View.OnClickListener带有下划线,它给出了错误“Class必须被声明为abstract或实现抽象方法”.这段代码大部分是从互联网上复制而来的,它假设工作正常.可能只是Android Studio错误.我怎样才能让它发挥作用?