code

How to format source code blocks in Scaladoc comments alvin June 10, 2017 - 4:38pm

As a quick note, if you want to embed a Scala source code example in your Scaladoc comments, just put the source code block in between {{{ and }}} characters in your comments, as shown in this example:

How to paste and load blocks of code in the Scala REPL alvin June 20, 2015 - 4:10pm

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 14.2, “How to paste and load blocks of code in the Scala REPL.”

Problem

You want to experiment with some code in the Scala REPL, and typing it in or trying to paste it into the REPL won’t work.

Source code for an Android ViewPager example (Activity and Fragment)

This is a little unusual for me, but I'm putting the following code here so I can remember how I implement a ViewPager in my current Android application. I want to put this code out here in its current state before it gets more complicated. In fact, I only wish I had copied it out here earlier, before I made it as complicated as it is.

The only things that are important to know are:

How to access an Android MenuItem from a Java Activity or Fragment alvin February 17, 2015 - 7:50pm

Here’s a quick example of how to access an Android MenuItem in a Java Activity or Fragment class (i.e., in your Java code).

Given a menu named res/menu/menu_landing_page.xml defined like this: