android

Android Adventures – Development Tips – Part 5

How to add the back button on the Activity Action Bar

If the character space stops working with EditBox when using Listeners
Probably it is the google keyboard trying to impose words instead of characters
The one solution that worked for me was to disable the text suggestions

android

Android Adventures–Development Tips-Parte 3

How to shrink activity layout when virtual keyboard is displayed and hides some of the views?
There are several different solutions, one of them is:

– In the AndroidManifest.xml, for the target activity

android:windowSoftInputMode=”adjustResize”

If you use Database Room framework for SQLite management and Kotlin:

If you are using Kotlin don’t create a new method, you can have compilation errors on the generated class

java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.
Solution 1: add allowMainThreadQueries

MyApp.database =  Room.databaseBuilder(this, AppDatabase::class.java, “MyDatabase”).allowMainThreadQueries().build()

Solution 2: Use another thread

Solution 3: If you use Kotlin 1.3+ you can use coroutines

How to explore a database in Android Emulator?
– You can copy the db files from the device to your computer and use a sqlite browser

– I use: Android Debug Database: https://github.com/amitshekhariitbhu/Android-Debug-Database

android

Android Adventures – Development Tips – Parte 2

How to add an icon to a button?
android:drawableLeft=”@android:drawable/ic_menu_search”
How to push a button in a LinearLayout to the right?
The trick in is the empty view

 

How to have an ImageButton transparent?
android:background=”@null”
How to clear all the Spannable styles in an EditText?
val currentPositionsInputText = contentTextEditBox.selectionStart
contentTextEditBox.setText(contentTextEditBox.text.toString())
android

Android Adventures – Development Tips

How to prevent an EditBox from expanding?

android:layout_width="0dp" – or height, depending the need and the use of the weight

android:layout_weight="1" – if you just have one and you want to fill the whole layout

How to add a Scrollbar to an EditBox?
android:scrollbars=”vertical”
How to write the text on top left of the EditBox?
android:gravity=”top|left”
How to avoid the overlap of the Toolbar with the included layout?
How to Highlight blocks of text in an EditBox?
Spannable spannable=new SpannableString(string);
// You can add other styles here, like bold, underline, other// if you are using a loop, put the Spannable construction outside the loop or sometimes only the last one will be used

spannable.setSpan(new ForegroundColorSpan(Color.BLUE), start, end, 0);
editText.setText(spannable);

InHash – Visual Studio Code Extension to Compute Hashs and Checksum

InHash – Visual Studio Code Extension to compute hash and checksum

I just developed the visual studio code version of the InHash plugin already developed for IntelliJ and Eclipse.

This plugin computes hash and checksum for files and selected text.

It started to be a necessity for a project where I was involved and “why not to create a plugin from it?”

Find it here: Visual Studio Code Extension to compute Hashs and Checksum

Error Message

Error: java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value

java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value

If this error occurs try addind the following dependencies to your pom.xml
Usually jackson needs these 3 dependencies:

  • databind
  • core
  • annotations

    com.fasterxml.jackson.core
    jackson-databind
    2.9.0

		

    com.fasterxml.jackson.core
    jackson-core
    2.9.0



    com.fasterxml.jackson.core
    jackson-annotations
    2.9.0

junit5

junit 5, maven dependencies

JUnit 5 and Maven Dependencies

Straight to the point:

You need at least these dependencies:


    org.junit.jupiter
    junit-jupiter-api
    5.1.0
    test



    org.junit.jupiter
    junit-jupiter-engine
    5.1.0
    test

There are other dependencies for IDEs and older versions of jUnit if you need them:


    org.junit.vintage
    junit-vintage-engine
    5.1.0
    test
    

    org.junit.platform
    junit-platform-launcher
    1.1.0
    test


    org.junit.platform
    junit-platform-runner
    1.1.0
    test