Java tutorial
//package com.java2s; import java.util.Map; import android.widget.TextView; public class Main { public static void setTextViewEx(Map<String, Object> m, TextView v, String key, String format) { String s = toString(m.get(key)); v.setText(String.format(format, s)); } public static void setTextViewEx(Map<String, Object> m, TextView v, String key, String format, String... en) { try { int i = Integer.parseInt(toString(m.get(key))); String s = en[i]; v.setText(String.format(format, s)); } catch (Exception e) { v.setText(""); } } public static String toString(Object obj) { if (obj == null) { return ""; } else { return (obj + "").trim(); } } }