我有许多不同颜色名称的按钮。选择一个按钮android
yellow - red - blue
我想,当一个用户点击它创建它周围的边框(选择按钮),在我的活动结束后我还有一个按钮,保存所选颜色的用户。
<Button
android:text="Yellow"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:id="@+id/button1" />
<Button
android:text="Red"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:id="@+id/button2" />
<Button
android:text="SAVE"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:id="@+id/buttonsave" />
的Java
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.color);
Button btnYellow;
btnYellow = (Button) findViewById(R.id.button1);
Button btnRed;
btnRed = (Button) findViewById(R.id.button2);
Intent intent = getIntent();
String url2 = intent.getStringExtra("image");
btnYellow.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
}
我怎么能选择一个按钮,当用户点击它,并得到一个值(红,绿,RED1),当用户点击保存?
您可以点击事件更改按钮的背景颜色 –
您需要的单选按钮或复选框,而不是常规按钮 –
首先我想选择一个按钮,当用户点击,如:红色。他们,当他点击“保存”时,我会显示一条消息,例如“红色”。 @Chetan –