Android DataBinding With Fragment

As we already know how to use DataBinding with Activity from Working with Data Binding Android article, but here we will see how to use DataBinding with fragment.

To bind a view of fragment we need to use onCreateView() . Here is a code snippet of fragment onCreateView()

Disable Landscape Mode In Android Application

As we have seen it creates so many problems when you rotate your device or when orientation is changed from portrait to landscape and vice-versa. However, there is a code to avoid that, but I have seen so many developers just disables landscape mode so that your application will be in portrait mode only all the time.

Whether rotation of device is on or off doesn’t matter, your application will be in portrait mode only.

To do that, you just need to add android:screenOrientation=”portrait” to an activity you have mentioned in the AndroidManifest.xml file.

Underlining text in TextView

As we all know there is a property called android:textStyle to set text as Bold and Italic. But it doesn’t have any value like underline. What if we want underlined text in android?

1st Approach

Continue Reading

ArrayAdapter in AlertDialog

We can always use ListView or RecyclerView for selection from list of items, but if we have small amount of choices and among those choices we want user to select one, we can use AlertDialog.Builder setAdapter.

Tip : ArrayAdapter in AlertDialog