List of usage examples for java.lang.reflect Field getShort
@CallerSensitive @ForceInline public short getShort(Object obj) throws IllegalArgumentException, IllegalAccessException
From source file:cz.tsystems.portablecheckin.MainActivity.java
private void populateTextsAndRbtn(ViewGroup theView) { String fieldName = ""; DMCheckin checkinData = app.getCheckin(); for (int i = 0; i < theView.getChildCount(); i++) { View v = theView.getChildAt(i); Class<? extends View> c = v.getClass(); fieldName = (String) v.getTag(); if (fieldName == null) continue; Field field = null; try {/* w w w . j ava2s . co m*/ field = DMCheckin.class.getField(fieldName.toLowerCase(Locale.ENGLISH)); } catch (NoSuchFieldException e) { Log.v(TAG, "NOT FOUND :" + fieldName.toLowerCase(Locale.ENGLISH)); continue; } Log.v(TAG, fieldName.toLowerCase(Locale.ENGLISH)); try { if (c == EditText.class || c == vinEditText.class || c == BaseEditText.class) { EditText editText = (EditText) v; editText.setText(""); if (field.get(checkinData) == null) continue; DecimalFormat nf = new DecimalFormat("#"); if (field.getType() == String.class)// jnCheckin.hasNonNull(fieldName)) editText.setText((String) field.get(checkinData)); else if (field.getType() == int.class) editText.setText(String.valueOf(field.getInt(checkinData))); else if (field.getType() == short.class) editText.setText(String.valueOf(field.getShort(checkinData))); else if (field.getType() == double.class) editText.setText(nf.format(field.getDouble(checkinData))); else if (field.getType() == Double.class) editText.setText(NumberFormat.getInstance().format((Double) field.get(checkinData))); else if (field.getType() == Date.class) editText.setText(sdto.format((Date) field.get(checkinData))); } else if (c == Switch.class) { ((Switch) v).setChecked(field.getBoolean(checkinData)); } } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }