All snippets tagged with java

Page 1 of 3
 

File I/O operations

Check and observe the availability of the Play Store.

Grant special permissions to a WebView

Accessing the camera or location in a WebView is not possible without granting the WebView permission. Make sure your app has permissions already through the conventional method before calling this snippet:

Read more…

Complete example of using a WebView

Wrapping a RecyclerView to the height of its content.

A View that shows a vertical, dotted line

Progress bar masked by text

Pie chart-like progress bar

This custom view shows a clock-like circular countdown, and can be used as a timer or as a ProgressBar. To use as a timer, create your own handler (or similar) to update the progress automatically.

Read more…

Using <ul> in TextViews

Underline text in a view

There’s no textStyle to add underline to a TextView or Button. Use the following to add it programmatically instead:

Read more…

Getting the screen size in pixels

Start by getting a reference to the WindowManager. When in an Activity, you can use getWindowManager(), otherwise, use:

Read more…

Bottom-to-top chat-style reversed RecyclerView

RecyclerView with CursorAdapter and reordering

This is a combination of a CursorAdapter fit for RecyclerViews, and several helpers to support drag-and-drop and swipe-to-dismiss.

Read more…

Using a RecyclerView

Using a theme to show a splash or placeholder while activity loads

Rule: never ever implement a splash screen using a separate activity. Splash screens should be used to show something while the app loads, and is not a way to delay app launch just to show a logo.

Read more…