Center Screen Two Android Buttons

Recently I was into a problem when I was unable to center screen two Android buttons, in a simplest way. My Google skills failed me to find a simple way, so I had to figure it out myself. I wanted my buttons to be centered horizontally and vertically on the screen. And those buttons would have certain widths. Like this one:

Center Screen Two Android Buttons

Centered Two Android Buttons

I got it by using these codes:

<?xml version="1.0" encoding="utf-8"?>

        android:text="Lovely Button"
        android:layout_weight="1.0" />
        android:text="Sweet Button"
        android:layout_weight="1.0" />

That’s it! :)

Enabling USB Debugging Mode for Android Devices

Enabling USB Debugging Mode for Android Devices

USB Debugging Mode for Android Device is a must when developing an Android application. It will save you a lot of time when debugging and executing your application. Please note that USB Debugging option might be disabled when your device is already connected to your PC. To enable it, you must disconnect it first and follow the steps given below.

I’m using a Galaxy Tab, so here’s what I did:
Touched Menu Soft Key &gt; Settings &gt; Touch Applications &gt; Development &gt; USB Debugging to be Checked
When you are able to check or enable the USB debugging mode option in your Android device, you would want to verify if your PC also detects it for your development. To do this, we have to follow the some simple steps.

Verify If Android Device is Attached to PC for Debugging

There was time when I was trying to run my Android code to my device but it seemed not working. One of the things I thought that causes this was if my Android device is really connected or attached to my computer. So I had to verify if it was. I’m using windows, so here’s what I did:

1. Execute the command prompt (cmd.exe)

2. Go to your Android SDK platform-tools directory. I had to execute cd c:Program FilesAndroidandroid-sdkplaform-tools in the command prompt

3. Check if ADB is present by executing adb, if you got those data rolled down, ADB is working fine.

4. See if your device is attached by executing adb devices, You should see your attached devices which look like something like this:

Verify If Android Device is Attached to PC for Debugging
Click to enlarge.
If no device was attached, you’ll receive a message of something like “Waiting for device”.

This is also where you can execute the ADB logcat which will make your life easier when debugging your Android App. You can do that by executing adb logcat

So that’s it, you can now run your code from eclipse. :)