我工作的一個女人懷孕的應用程序。 我正試圖讓寶寶踢上櫃臺。 點擊按鈕後,計數器增加。 但我希望每次點擊,按鈕顏色都像網頁懸停一樣。 我嘗試的onclick但一次改變結腸後來沒有改變如何改變我的顏色按鈕顏色
此示例代碼點擊數
@Override
public void onClick(View v) {
if(v == counterbutton) {
counterbutton.setBackgroundColor(getResources().getColor(R.color.blue_background));
get_last_counter++;
SharedPreferences.Editor editor = MotherActivity.preferences.edit();
editor.putInt(MotherActivity.COUNTER_INCREASE, get_last_counter);
editor.apply();
counter.setText(counter_writer(get_last_counter));
}
}
按鈕的XML代碼
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="@string/kick"
android:id="@+id/counterbutton"
android:background="@color/app_pink"
android:textColor="@color/blue_text_color"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true" />
對不起不好英語。 謝謝。
是爲真正的答案感謝名單:) –