step 1:
<ImageButton
android:id="@+id/alarm"
android:layout_width="25dp"
android:layout_height="25dp"
android:background="@drawable/alarm_on" />
step 2:
public class MainActivity extends AppCompatActivity {
ImageButton alarm;
int a;
@Overrideprotected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_remainter);
alarm= (ImageButton)findViewById(R.id.alarm);
View.OnClickListener imgButtonHandler = new View.OnClickListener() {
public void onClick(View v) {
boolean clicked = true;public void onClick(View v) {
if(!clicked){
b1.setBackgroundColor(Color.RED);
clicked = true;
//here i will update the database
}else{
b1.setBackgroundColor(Color.BLUE);
clicked = false;
//here i will update the database }
}
};alarm.setOnClickListener(imgButtonHandler);
No comments:
Post a Comment