im_chc
im_chc

Reputation: 1075

Shortcut key to switch between XML layout and the java class in eclipse (android )

I'm not putting much hope in getting this problem solved, but this is really a pain and I really hope that this can be sorted out...

It is that, is there a shortcut key in Android Eclipse to switch between an xml layout file and its "related" java class (e.g. activity) source file? Much like Visual Studio's Windows Forms Designer (F7 to switch between design view and source code view).

I know that there is not a declarative definition on the relationship of an XML layout and an Activity/Fragment, it is determined during runtime... but still, it is an incredible pain when you are in the source code view and want to refer to a view by id but you (always) cannot remember the name, you need to scan through millions of files in millions of levels of tree depths in the Package Explorer view.

I feel like giving up even now... no one can help...

Upvotes: 3

Views: 4250

Answers (5)

LordWabbit
LordWabbit

Reputation: 347

You can also use bookmarks, not exactly what you asked for but can be helpful when jumping around.

F11 - Toggle soft bookmark
Shift + F11 - Open bookmark menu
Ctrl + F11, [mnemonic key] - Create a bookmark with a mnemonic key entry - press any number or letter afterwards
Ctrl + [mnemonic key] - jump to the bookmark created with Ctrl + F11.

Like I said, won't help if you are in the layout and want to jump to the "code behind" but it's a quick way to move between the two while working if you have left bookmarks.

Upvotes: 0

Manish Kumar Sharma
Manish Kumar Sharma

Reputation: 13442

If you have selected a view in Design View and want to move onto Text View,

CTRL + B

Upvotes: 0

TheIT
TheIT

Reputation: 12219

In Android Studio, you can make use of the Related Symbol... navigation key mapping to toggle between related XML and Java classes.

Depending on your settings and operating system the keyboard shortcut will vary, but you can find out what yours is by looking in Settings -> Keymap -> Main menu / Navigate / Related Symbol...

Otherwise try the following keys:

Ctrl + Alt + F7
Ctrl + Alt + Home
Meta + Ctrl + Up

Upvotes: 3

Alfredo
Alfredo

Reputation: 47

In android studio it's ctrl+tab

Upvotes: 3

Gabe Sechan
Gabe Sechan

Reputation: 93668

No, because there isn't a 1:1 relationship between activities and layouts. One activity can have multiple layouts, and 1 layout can appear in multiple activities. I suggest you either adopt a naming standard so you don't have these problems, or just manually open the xml file and keep it open.

Upvotes: 4

Related Questions