setOnClickListener需要在方法里面调用,比如可以放在onCreate()方法中。另外,你的第二个setOnClickListener的C应该大写的,写成小写了。
解决方案 »
- 超炫的3D桌面,多种特效,TSF桌面演示版,现在分享给各位
- vs2008 C++ 搭建Andorid 开发环境可以吗?
- ListView控件
- 【急急急】【Android下根据通话记录表中的字段信息查询对应的联系人图像?】
- Android开发从〇开始(3): 打包
- 如何在自定义的MapView上绘制路径
- 请教android2.2怎么格式化SDcard?
- 关于android开发的google map 和location问题
- 为什么百度地图在有的手机上显示有的手机上不显示 我运行的是baiduMapsdkDemo
- 关于微信分享
- android:fontFamily 属性的使用
- 使用Git上传Android代码
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.view.Menu;
public class MainActivity extends Activity {
private TextView show;
private Button press;protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);show=(TextView)findViewById(R.id.show_TextView);
press=(Button)findViewById(R.id.Click_Button);
press.setOnClickListener(new View.OnClickListener(){
public void onclick(View v){
show.setText("button 被点击了");
}
});
}@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;}}重新帮你整理了下,你的事件与初始化应该放在onCreate里面