Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Hotkey for navigating to xml declaration is instead navigating to R file

Original Title: What is the hotkey, if any, for navigating to layout file or a resource's value?

(This question didn't really describe the issue at hand. And as you can imagine, it attracted some obvious answers. My apologies, this is the first question I've posted.)

I'm using Android Studio version 1.1.0 on Mac.

Say I have a line of code similar to this:

    setContentView(R.layout.layout_main);

In Eclipse, I could simply use 'command + click' on the resource ID and it would navigate to the respective xml file then highlight the string, view, or color declaration. However, doing so in Android Studio navigates me to the declaration within the R file, which is utterly useless.

Is there a separate hotkey that I missed, or a separate event/action I could bind the current hotkey to, that would cause AS to operate more like Eclipse in this manner?

EDIT

After a couple answers -- which were correct according to the original question -- and some experimentation (created a fresh new project - I feel silly for not doing that earlier), it seems Android Studio should in fact navigate to the exact line in the xml where the View, String, or Color resource is declared, just like Eclipse does. However in my situation, it isn't for some odd reason.

This is merely speculation, but I suppose the culprit could be one or a combination of three things:

  1. The project I was working on - It was recently migrated from an Eclipse project to Android Studio project. This seems to be the most likely since the issue persists after updating items 2 and 3.
  2. The JDK version - When I created the new project, AS complained that my compiler was outdated (was running 1.6, upgraded to 1.7).
  3. Target SDK - the reason I was prompted to upgrade the JDK.
like image 743
user3829751 Avatar asked Mar 16 '15 16:03

user3829751


People also ask

How to fix indentation in Android Studio?

Shift + Tab to decrease the indent.

How to select methods to override implement in Android Studio?

Just press CTRL+O on Windows or Command+O on Mac and you'll be presented with a list of methods that you can override.

How to auto align code in Android Studio?

Automatically formatting code in Android Studio and IntelliJ To automatically format your code in the current source code window, use Cmd+Alt+L (on Mac) or Ctrl+Alt+L (on Windows and Linux).

How to set keymap in Android Studio?

To open the keymap settings, choose File > Settings (on Mac, Android Studio > Preferences) and navigate to the Keymap pane. Figure 1. The Android Studio keymap settings window. Keymaps dropdown: Select the desired keymap from this menu to switch between preset keymaps.


1 Answers

CTRL + B should do it. Otherwise you can create your own shortcuts.

like image 180
Catalina Avatar answered Nov 15 '22 08:11

Catalina