Android Layout Finder | Buzzing Android

The Android Layout Finder helps you create the code that ties your Android UI and Java code together.

It's real easy! Just paste your Android XML layout code in the first text field, pick the views that you need, and your code is automatically generated for you.

No more typing out all those nearly identical findViewById() and findFragmentById() calls in your activities or fragments whenever you change your Android layouts.

1. Enter Android XML Layout:

Paste in your Android XML Layout code

2. Pick your Views:

Select the views that you need to interact with

3. Get your Java code:

Click on the code to select the entire text

public class MyCursorAdapter extends CursorAdapter {

	private static class ViewHolder {
		public final RelativeLayout rootView;
		public final RelativeLayout RLayout;
		public final TextView lblComments;
		public final EditText txtComments;
		public final Button btnSave;
		public final Button btnCancel;
	
		private ViewHolder(RelativeLayout rootView, RelativeLayout RLayout, TextView lblComments, EditText txtComments, Button btnSave, Button btnCancel) {
			this.rootView = rootView;
			this.RLayout = RLayout;
			this.lblComments = lblComments;
			this.txtComments = txtComments;
			this.btnSave = btnSave;
			this.btnCancel = btnCancel;
		}
	
		public static ViewHolder create(RelativeLayout rootView) {
			RelativeLayout RLayout = (RelativeLayout)rootView.findViewById( R.id.RLayout );
			TextView lblComments = (TextView)rootView.findViewById( R.id.lblComments );
			EditText txtComments = (EditText)rootView.findViewById( R.id.txtComments );
			Button btnSave = (Button)rootView.findViewById( R.id.btnSave );
			Button btnCancel = (Button)rootView.findViewById( R.id.btnCancel );
			return new ViewHolder( rootView, RLayout, lblComments, txtComments, btnSave, btnCancel );
		}
	}

	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		ViewHolder vh = (ViewHolder)view.getTag();

		// Bind your data to the views here
	}
	@Override
	public View newView(Context context, Cursor cursor, ViewGroup parent) {
		View view = inflater.inflate( R.layout.listitem, parent, false );
		view.setTag( ViewHolder.create( (RelativeLayout)view ) );
		return view;
	}

	private LayoutInflater inflater;

	// Constructors
	public MyCursorAdapter(Context context, Cursor c, boolean autoRequery) {
		super(context, c, autoRequery);
		this.inflater = LayoutInflater.from( context );
	}
	public MyCursorAdapter(Context context, Cursor c, int flags) {
		super(context, c, flags);
		this.inflater = LayoutInflater.from( context );
	}
}
Android Layout finder is made by Jesper Borgstrup 2013. Using jQuery, Dynatree and Twitter Bootstrap.
Android Layout Finder is licensed under the GNU General Public License and the source code is available at GitHub.