Posts Tagged ‘Eclipse’

Setting print margins using Eclipse to maintain line character length

Friday, May 14th, 2010

Sometimes you may have standard line lengths with which to work when writing code. If this is the case and your using Coldfusion and Eclipse with the cfEclipse plugin you can maintain the character length consistency by setting up the print margins to n character length.

Point being that when running the cfeclipse plugin you need to choose CFEclipse > Editor in the preferences left navigation. In the options you will check ‘Show print margin’, set the ‘Print margin column’ text field to the desired character length, and if you choose the ‘Print margin’ option in the ‘Appearance color options’ select box. Then choose the color you wish the margin to be. This will set a line length that will show in the code editor pane. Of course it will not wrap the line. It is still your duty as a developer to wrap appropriately. Nonetheless it does give you a guide for where the line should wrap at least.

If you’re writing Java then you would select General > Editor > Text Editors in the preferences pane.  Although the display is slightly different, generally follow the same steps as above for showing the print margin.

If you’re using Coldfusion Builder you will follow the same exact directions as listed just above for showing the print margins writing Java.

Lastly, if you’re using Flex Builder 3 you will again follow the same directions as above for showing print margins writing Java.

Android LinearLayout tag not stacking elements

Thursday, May 6th, 2010

This is really more of a reference for myself than anything else.  Point being I just spent about half an hour trying to figure out why my TextViews were not showing up in my LinearLayout for my Android application.  What I was getting was the top level TextView but none of the others below it.  As I moved them around in their order I realized that they were there, but falling behind the TextView on top.  So, clearly, the issue is that they are layering instead of stacking.

Just to make sure we’re all on the same page in resolving this issue (which is really not an issue at all) we’re working on a layout XML file for an Android application.  So if you’re using the built-in Eclipse Android plugin you will have a main.xml file by default in the res/layout directory.  If you delete the XML from this file and add a new LinearLayout from the layout perspective, and then add some TextViews or whatever, you’ll notice that only the top one shows.

So for example.

Does not work

<LinearLayout 	android:id="@+id/LinearLayout01"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			xmlns:android="http://schemas.android.com/apk/res/android"
			android:background="@android:color/black">

</LinearLayout>

and…

Does work

<LinearLayout 	android:id="@+id/LinearLayout01"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			xmlns:android="http://schemas.android.com/apk/res/android"
			android:background="@android:color/black"
			android:orientation="vertical">

</LinearLayout>

For whatever reason, when you add a LinearLayout like this it does not include the ‘android:orientation=”vertical | horizontal”‘ attribute.  Apparently this is a pretty important attribute.  This determines if the assets stack horizontally or vertically.  And if not specified no error is thrown, instead it just seems to layer, or possibly just show the top asset.  Doesn’t really matter as far as I see it.  For those of us who have no idea what we’re doing it should seriously throw an error or something.

Device does not show up in Eclipse ‘Android Device Chooser’

Thursday, May 6th, 2010

This is just a quick note on how to make sure your device shows up in the device listing when debugging an Android app in Eclipse. I spent some time trying to figure this out since I had the plugins all installed and the app ran good in the Emulator, but my device just wouldn’t show up in the device list when choosing to debug manually. I found the solution, of course, in the docs.

So if you’re having this problem you should make sure that your device is set up for debugging. I’m running the Droid Incredible, so you may need to take slightly different steps to accomplish this than what I layout here.

  1. On the home screen of your device choose Menu > Settings > Applications > Development.
  2. Make sure that ‘USB debugging’ is checked. I would also suggest checking the ‘Stay awake’ option as well so you don’t have to keep waking your phone up during debugging.

If the rest of your debug settings are correct your device should show up.  At least for me this was the solution.