Hi guys, hope you had a great new years!
If you’ve ever developed an Android app, you’ve probably used the findViewById()
method for finding views and findFragmentById()
for finding fragments from your inflated layout. This has to be done with every View and Fragment that you want to access from your code.
After getting tired of writing the same code over and over again, I created a tool to generate that code for me from an arbitrary XML layout:
Behold: The Android Layout Finder!
You can try it out on a sample XML layout by pressing the ‘Paste example XML’ button in the right side of the screen.
Android Layout Finder is open source and licensed under the GNU General Public License. The code can be found on GitHub: http://www.github.com/jesperborgstrup/android-layout-finder. Enjoy!
Hey, I love your layout finder. It’s great. It’d be even greater if you could add a feature so that when there is a button/imagebutton it adds setOnClickListener(this) and the onClick(View arg) with the switch case inside for all the ids of the buttons/imagebuttons on the Activity! That would be neat and would save a lot of fiddling!
Thanks again!
This is actually a great idea. I have just implemented this for the “Member variables” code type. The option is enabled by default, and can be disabled by unchecking the “Implement ClickListeners for Buttons and ImageButtons” option.
Thank you for your input
Awesome tool. I’ve started using your tool to generate the boilerplate code. It saves time. Thanks.
This is exactly what I was looking for, real time saver.
suggestions: There should be ability to put onlicklistener to other views like edittext and textview, plus It would be great if tool allow user to select views he want onclicklistener.
Great thanks for this cool tool
I love your tool but I use androidannotations. It’s almost the sama as RoboGuice but instead of @InjectView androidannotations library uses @ViewById. It will be simple to implement and very helpful. Great job!
Thank you very much for this tool ! It’s really usefull.
I have the same suggestion than the previous comment. I use some ImageViews and TextViews which I need to config their onClickListeners. It would be nice to add this to these views as well.
Thanks!
Nice tool! It would be nicer if it can handle “include” tag in XML and generate the Java code for the elements in included XML.
Keep on good work!
Nice tool! =)
For ArrayAdapter with ViewHolder you can make your code easier. =))
viewHolder = ViewHolder.create((RelativeLayout) convertView);
replace to:
viewHolder = new ViewHolder((RelativeLayout) convertView);
class ViewHolder should be similar to this:
private static class ViewHolder {
public final TextView field;
private ViewHolder(RelativeLayout rootView) {
field = (TextView) rootView.findViewById(R.id.field);
}
}
It would be nice if you did. Thank you for your service! =)
Thank you so much for your effort
this tool is just what I wanted !
I think it would be super awesome if you can exclude a prefix from the id as many people name their id’s with a prefix for each XML file.
Keep the GREAT work !
Cheers.
Hello, and thank you for your comment.
I have added the feature (“Remove ID prefix” in General settings)
Hope you like it!
Cheers
Thank you so much !
Hi
Thank you for this amazing tool! Could you please add support to ButterKnife!
Thank you.
Hi, I think that the code is pretty similar to the RoboGuice code that is already supported.
If there are any differences, please ley me know so I can try to implement it as well.
Awesome and very useful tool. Good job, man!
Pingback: آزمایشگاه تمرین – پیدا کردن محتویات لی اوت بصورت اتوماتیک