Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Blog Reader Android App Using Intents to Display and Share Posts Easy Sharing with Intents

Noam Elbaz
Noam Elbaz
5,672 Points

Android Studio - Extract a string - (Refactor)

The video called "Easy sharing Intents" Ben extracts a string from code and easily refactors to strings.xml in Eclipse. I'm on Android Studio.

Anybody know how to do it?

I tried highlighting the string and "Reactor" ... but i did not see anything that matched.

I tried Googling it but no success.

Thanks

Mohammad Abdirashid
Mohammad Abdirashid
8,211 Points

Highlight the String you want to refactor to create the string, and then use Shift + F6

I use Mac, and use fn+shift+f6

Patrick Allwood
Patrick Allwood
7,463 Points

Highlight the string and click alt/option and enter (on a mac). This will bring up a context menu which will give you the option to extract a string resource.

Ralph Cacho
Ralph Cacho
8,698 Points

Place your mouse cursor over the string you want to extract and click once. A yellow light bulb (warning) should show up to the left between the line numbers and the of the line of code. Click the light bulb and select "Extract string resource" then fill in the appropriate fields. Hope this helps!

1 Answer

Ian B
Ian B
2,688 Points

Highlight the text and then press Alt + Enter. Select it from the options that appear.