gpt4 book ai didi

android - "id"下的红色波浪线

转载 作者:行者123 更新时间:2023-11-29 22:26:47 26 4
gpt4 key购买 nike

在下面的 fragment 中,“id”出现的任何地方都有一个红色的波浪下划线(左边距有一个红色的方形-X-paired-w/-a-'灯泡'图标:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//the id of the main layout was manually added in the XML file!
LinearLayout ll = (LinearLayout) findViewById(R.id.main_layout);

recButton = (Button) findViewById(R.id.recButton);
recButton.setEnabled(true);
recButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
startRecording();

}
});

stopButton = (Button) findViewById(R.id.stopButton);
stopButton.setEnabled(false);
stopButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
stopRecording();
}
});

playButton = (Button) findViewById(R.id.playButton);
playButton.setEnabled(false);
playButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
playRecording();
}
});

analyzerButton = (Button) findViewById(R.id.analyzerButton);
analyzerButton.setEnabled(false);
analyzerButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
analyzeRecording();
}
});

audioShape = new AudioShape(this);
ll.addView(audioShape);
}

Mouseover 是“id 无法解析或不是字段。”

我只是将一些开放数据工具包 (ODK) .java 文件复制到一个新的 Android 启动器 Hello 型应用程序中。没有做任何其他事情,当然还没有为它创建任何 UI(我需要吗?)。我插入 Eclipse 的文件是这样的:http://code.google.com/p/opendatakit/source/browse/src/net/hugo/audioAnalyzer/?repo=listen&r=1146e38a2c144b6b338f694bc39fda3c26c3d1e1

不知道如何进行。感谢您的帮助。

最佳答案

您确实需要为其创建新的 UI。当您添加自定义 ID 时,例如android:id="@+id/myButton" 到布局文件(res/layout 下的 XML 文件)中的元素,Android 构建系统将生成一个 ID 常量 R.id.myButton 在您项目的自定义构建 R 类中。因此,从您的示例项目中找到主要布局并将其复制过来。

关于android - "id"下的红色波浪线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5678965/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com