小女女是菜鸟,最近刚开始看Android,这是一段疯狂Android讲义里面的代码,想试试看,发现会一直报错滴说
package com.example.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Button;
public class HelloWorldActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello_world);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.activity_hello_world,menu);
return true;
}
public void clickHandler(View source)
{
TextView tv=(TextView) findViewById(R.id.show);
tv.setText("Hello Android-" + new java.util.Date());
}
}
其实是两个错误
Description Resource Path Location Type
menu cannot be resolved or is not a field HelloWorldActivity.java /HelloWorld/src/com/example/helloworld line 20 Java Problem
Description Resource Path Location Type
The method setText(String) is undefined for the type TextView HelloWorldActivity.java /HelloWorld/src/com/example/helloworld line 26 Java Problem
请各位高手帮忙啊~
Project > Clean.
import android.R;
或者
import your.application.packagename.R;