DisplayMessageActivity无法解析为类型构建的第一个android应用 [英] DisplayMessageActivity cannot be resolved to a type-Building first android App

查看:125
本文介绍了DisplayMessageActivity无法解析为类型构建的第一个android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始在 developer.android.com 上开发第一个android应用程序.

Hi I have just began working on the first android application on developer.android.com.

首先,我必须从S.O学习许多错误根源及其解决方案.,但是我一直在努力弄清楚这句话"DisplayMessageActivity无法解析为类型" ,而我们必须为按钮onclick函数设置一个Intent.它在代码行所在的行中显示此错误:

well to start with I got to learn many error origins and their solutions from S.O. , but i have been trying to figure out this statement "DisplayMessageActivity cannot be resolved to a type" while we have to set an Intent for button onclick function. It shows this error in the line where the code line is:

Intent intent = new Intent (this, DisplayMessageActivity.class);

这是Java文件:

MainActivity.java

}
/**called when the user clicks the send button*/
public void sendMessage(View view) {
    Intent intent = new Intent (this, DisplayMessageActivity.class);
    EditText editText = (EditText) findViewById (R.id.edit_message);
    String message = editText.getText().toString();
    intent.putExtra(EXTRA_MESSAGE, message);
    startActivity (intent);
}
}

我尝试了很多,现在我需要导入哪个类,并进行了搜索,但无济于事.可能我是初学者是我在这里想念的.

I tried a lot find which class do I need to import now, and searched but no avail. may be I am a beginner is what I miss here.

推荐答案

好吧,我认为答案为时已晚,也许您已经知道了.但是,以防万一,我想再作一些解释.

Well, I think it's too late to answer and probably you figured out already. However, just in case I'd like to put some more explanation.

发布问题后,他们的构建第一个应用程序"的开始另一个活动"部分可能已被修改,但是我发现用户定义的"DisplayMessageActivity"在下面的几行中进行了定义,在这些行中,您被引导编写代码来创建目的,因此请参阅DisplayMessageActivity.在创建第二个活动"部分,创建了DisplayMessageActivity.

Probably their "Starting Another Activity" section of Buidling Your First App" was revised after you posted your question, but I found that the user-defined "DisplayMessageActivity" is defined several lines below where you were guided to write code to create Intent and thus refer to DisplayMessageActivity. At "Create Second Activity" section, the DisplayMessageActivity is created.

好吧,Google的教学风格不好,我发现他们的框架设计(因而命名)不好,并且没有揭示它们的含义.但是..如果您选择要开发的Android平台,除了忍受之外您还能做什么?祝你好运.

Well, Google's pedagogy style is not good, and I found out that their framework design ( and thus naming ) is not good and doesn't reveal what they are. But.. if you choose Android platform to develop for, what can you do other than endure that. Good luck with that.

这篇关于DisplayMessageActivity无法解析为类型构建的第一个android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆