Time-saver! creating Android string resources directly from code.

Let’s say you copy and paste an XML TextView:

 

<TextView 
  android:id="@+id/whatever"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="@string/copy_pasted_string"/>

 

You probably won’t have the “copy_pasted_string” defined in the strings.xml file, and creating it manually is slow.

On Eclipse, place the mouse over the “copy_pasted_string” text, press CTRL+1 then click “Rename Android resource”.

It will create a new strings.xml entry, plus a new R.string resource in the R.java file.

Saved me thousands of seconds of routinary work!

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s