1public class MainActivity extends Activity {
[email protected]
3 protected void onCreate(Bundle savedInstanceState) {
4super.onCreate(savedInstanceState);
5 setContentView(R.layout.activity_main);
6 Button bn = (Button)findViewById(R.id.button1);
7 bn.setOnClickListener(new onClickListener(){
8 public void onClick(view v)
9 {
10 final TextView show = (TextView)findViewById(R.id.textView1);
11 show.setTxet("Hello Android~"+new java.util.Date()) ;
12 }
13 }
14 );
15 }
第7排代码报错是: Multiple markers at this line
- onClickListener cannot be resolved to a type
- The method
setOnClickListener(View.OnClickListener) in the type View is
not applicable for the arguments (new onClickListener(){})
然后第8排代码报错:view cannot be resolved to a type
最后11排代码报错是:The method setTxet(String) is undefined for the type
TextView
谁能给我说一下这些都是些什么错么?我就是想实现一个按键监听,结果编了几排就错了这么多。。==#
------解决方案--------------------
import android.view.View.OnClickListener;
------解决方案--------------------
show.setTxet("Hello Android~"+new java.util.Date()) ;
你的new java.util.Date() 类型不正确,settxet 参数是 String
第7行 在前面加上 import android.view.View.OnClickListener; 这个试下