hate_debug 2014-09-01 15:21 采纳率: 0%
浏览 2965

菜鸟一枚~tv.setText("Hello Android-" + new java.util.Date());这个一直报错滴说

小女女是菜鸟,最近刚开始看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

请各位高手帮忙啊~

  • 写回答

1条回答 默认 最新

  • 流苏1990 2014-09-02 07:17
    关注

    Project > Clean.

    import android.R;
    或者
    import your.application.packagename.R;

    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试