立即扫描或立即生成二维码按钮?
scan Now or Generate Now QR Code button?
所以,我想要在我的应用程序中使用这样的按钮:
我不知道如何给android-studio中的按钮加码,我只有扫描码。我不知道如何将 2 个函数放在同一个项目中。我应该怎么办?有人能帮我吗?
听起来您需要添加一个函数来处理 OnClick
事件。 The Android documentation has a nice example on how to set and OnClick
listener:
<Button
android:id="@+id/button_id"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/self_destruct" />
public class MyActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_layout_id);
final Button button = findViewById(R.id.button_id);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Code here executes on main thread after user presses button
// This should be where you add your button logic.
}
});
}
}
所以,我想要在我的应用程序中使用这样的按钮:
我不知道如何给android-studio中的按钮加码,我只有扫描码。我不知道如何将 2 个函数放在同一个项目中。我应该怎么办?有人能帮我吗?
听起来您需要添加一个函数来处理 OnClick
事件。 The Android documentation has a nice example on how to set and OnClick
listener:
<Button
android:id="@+id/button_id"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/self_destruct" />
public class MyActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_layout_id);
final Button button = findViewById(R.id.button_id);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Code here executes on main thread after user presses button
// This should be where you add your button logic.
}
});
}
}