Android Preventing Double Click On A Button

What is the best way to prevent double clicks on a button in Android? 52 Answers 52 saving a last click time when clicking will prevent this problem. i.e. private long mLastClickTime = 0; … // inside onCreate or so: findViewById(R.id.button).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // mis-clicking prevention, using threshold of … Read more

Override back button to act like home button

On pressing the back button, I’d like my application to go into the stopped state, rather than the destroyed state. In the Android docs it states: …not all activities have the behavior that they are destroyed when BACK is pressed. When the user starts playing music in the Music application and then presses BACK, the … Read more

Coloring Buttons in Android with Material Design and AppCompat

Before the AppCompat update came out today I was able to change the color of buttons in Android L but not on older versions. After including the new AppCompat update I am unable to change the color for either version, when I do try the button just disappears. Does anyone know how to change the … Read more

Android customized button; changing text color

I made a button that changes the background drawable on different states, this way: <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_pressed=”true” android:drawable=”@drawable/btn_location_pressed” /> <!– pressed –> <item android:state_focused=”true” android:drawable=”@drawable/btn_location_pressed”/> <!– focused –> <item android:drawable=”@drawable/btn_location”/> <!– default –> </selector> The problem here is that I’m also trying to change the textColor as I do with the drawable but I’m … Read more

Android Material Design Button Styles

I’m confused on button styles for material design. I’d like to get colorful raised buttons like in the attached link., like the “force stop” and “uninstall” buttons seen under the usage section. Are there available styles or do I need to define them? http://www.google.com/design/spec/components/buttons.html#buttons-usage I couldn’t find the default button styles. Example: <Button style=”@style/PrimaryButton” android:layout_width=”wrap_content” … Read more

Why is my Button text forced to ALL CAPS on Lollipop?

In my app “Tide Now WA” which I recently tested for compatibility using the new Nexus 9 tablet (Lollipop – API 21). It writes some button text. This app writes the text correctly using Android 2.3 and Android 4.0. I.e. mixed capital and lower case letters. When same app is run on my Nexus 9 … Read more