The easiest way I found is using the command-line terminal:
~$ date -r 1322532029
Tue Nov 29 10:00:29 SGT 2011
Unfortunately, as are other Android SDK documentation, this doesn't tell you much which methods gets inlined with machine code.In addition to all the usual reasons to prefer library code over rolling your own, bear in mind that the system is at liberty to replace calls to library methods with hand-coded assembler, which may be better than the best code the JIT can produce for the equivalent Java. The typical example here isString.indexOf
and friends, which Dalvik replaces with an inlined intrinsic. Similarly, theSystem.arraycopy
method is about 9x faster than a hand-coded loop on a Nexus One with the JIT.
public void start() { if (!isRunning()) { run(); } }
public View getView(int position, View convertView, ViewGroup parent) { View v; if (convertView == null) { v = LayoutInflater.from(getApplicationContext()).inflate(R.layout.row, null); } else { v = convertView; } // later: return v; }
View v = convertView != null? convertView: LayoutInflater.from(getApplicationContext()).inflate(R.layout.row, null);
TextView lAddress = (TextView) findViewById(R.id.lAddress);
ImageButton bSubmit = (ImageButton) findViewById(R.id.bSubmit);
/** * Convenience method of findViewById */ @SuppressWarnings("unchecked") public static <T extends View> T getView(View parent, int id) { return (T) parent.findViewById(id); } /** * Convenience method of findViewById */ @SuppressWarnings("unchecked") public static <T extends View> T getView(Activity activity, int id) { return (T) activity.findViewById(id); }
TextView lAddress = getView(this, R.id.lAddress); // or, if not inside an activity, let's say in an Adapter's getView: View res = convertView != null? convertView: getLayoutInflater().inflate(R.layout.item_person, null); TextView lAddress = getView(res, R.id.lAddress);