[Android] imeOptions not working on EditText (actionNext, actionDone)

Don’t forget to add

<item name=”android:inputType”>text</item>

or

<item name=”android:inputType”>textPassword</item>

to your EditText’s style

Directly on XML:

<EditText
style=”@style/PasswordEditText”
android:id=”@+id/login_et_password”
android:layout_below=”@+id/login_tv_password”
android:inputType=”text”
android:imeOptions=”actionDone”
/>

Advertisements

[Android SDK] Using variables from Gradle, in Java code

This is a pretty simple issue, but I’ve seen many questions and bad solutions about it.

An example of doing that could be:

file: app/build.gradle

android{
   buildTypes{
       release{
           buildConfigField "int", "SAMPLE_INT", "52"
           buildConfigField "boolean", "SAMPLE_BOOL", "true"
           buildConfigField "String", "SAMPLE_STR", "\"release_foo\""
       }
       debug{
           buildConfigField "int", "SAMPLE_INT", "55"
           buildConfigField "boolean", "SAMPLE_BOOL", "false"
           buildConfigField "String", "SAMPLE_STR", "\"debug_foo\""
       }
   }
}

file: MainActivity.java

@Override
 protected void onCreate(Bundle savedInstanceState){
     String gradleStr = BuildConfig.SAMPLE_STRING;
     int gradleInt = BuildConfig.SAMPLE_INT;
     boolean gradleBool = BuildConfig.SAMPLE_BOOL;
 }

As simple as that 🙂

hope it helps for you!

[Android SDK] Useful keyboard shortcuts for Android Studio

The ones I use most:

While developing

Alt+enter over class in code (.java): Quick assistance (import class, override methods, etc)
Alt+enter over string in code (.java): Extract string resource (include in res/values/strings.xml)
Alt+enter over string in resource file (.xml): Extract string resource (same as previous)

Shift+Cmd+F9: Make module (only current module)
Shift+Cmd+UP: Move this line UP (in .java)
Shift+Cmd+DOWN: Move this line DOWN (in .java)

Ctrl+R (aka ^ R): Run
Ctrl+Alt+D: Debug
Ctrl+Alt+I: Auto-indent code

Cmd+Backspace: Remove current line (VERY USEFUL)
Cmd+D: Duplicate current line (VERY USEFUL)

Cmd+F9: Make project  (all modules, app, wear, glass..)

When debugging:

F8: Step over
Cmd+Alt+R: Continue execution (what a weird shortcut this one)

I’ll keep completing it everytime I find a really useful one. Feel free to post your own in comments!