我有以下问题。我在应用程序 bluetoothChat 中添加了一些按钮,通过单击它们发送特定文本。为此,我输入了程序的名称,应该通过单击 onClick 属性中的按钮来启动。例如:onClick = haloClick。
我将此添加到代码中:
public void halloClick(View view) {
sendMessage("Hallo");
}
到目前为止,它完成了它的工作。每次我按下按钮“你好”都会发送。
现在我添加了一个按钮和一个搜索栏。我希望每次按下按钮时都会发送搜索栏的值。所以我将按钮的 onClick 设置为“sendValue”,并添加了我在 Internet 上找到的以下代码女巫:
public void sendValue(View view) {
sendMessage(seekBar1.getProgress ());
}
Eclipse 显示错误:seekBar1 无法解析。
我的错误在哪里?在 Layout 中,seekbar 是这样实现的:
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="0"/>
谢谢你的帮助!