Java tutorial
//package com.java2s; import java.lang.reflect.Field; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ImageView; import android.widget.TextView; public class Main { public static void intentToAndroidLayoutMapper(Class<?> classObj, Intent intent, String prefixStr, Activity view) { Bundle map = intent.getExtras(); for (Object keyObj : map.keySet().toArray()) { String keyStr = keyObj.toString(); Field fieldObj = null; try { fieldObj = classObj.getField(prefixStr + "_" + keyStr); } catch (NoSuchFieldException e) { continue; } Object layoutObj = null; try { layoutObj = fieldObj.get(fieldObj); } catch (IllegalAccessException e) { continue; } Integer layoutIntvalue = (Integer) layoutObj; View selectedView = view.findViewById(layoutIntvalue); if (selectedView instanceof TextView) { TextView textView = (TextView) selectedView; textView.setText((String) map.get(keyStr)); } else if (selectedView instanceof ImageView) { ImageView imageView = (ImageView) selectedView; } } } }