Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refactoring/Renaming Variable in Android Studio Project

I'm writing a little Android App and things are working out nicely, actually. The only problem I'm facing is that Android Studio won't let me refactor all of the occurrences of the variable I inted to rename (see: attached link).

I'm simply using the Alt-Shift-R Shortcut, entering the wanted text and pressing enter. The field variable is changed - but its occurences (though highlighted before) aren't. Using the preview window doesn't change the outcome.

Am I missing anything? I feel like a moron. :')

Variable naming after hitting Enter-Button

  • valueAusgabe is the previous naming
like image 866
Prometheus Avatar asked Nov 28 '22 16:11

Prometheus


2 Answers

If you're on Windows or Linux you should be able to rename all occurrences of your variable (variableAusgabe) by just using the Ctrl+Shift+R shortcut.

When you use this, a pop-up shows up and you have to enter the text you want to replace (variableAusgabe), and the text you want to replace it with. Select Refactor for each occurrence or Replace All.

like image 77
8bit an3 Avatar answered Dec 09 '22 17:12

8bit an3


In Android Studio (ver.3.1) shortcut for Refactor/Rename is: Shift+F6.

like image 38
Davor Avatar answered Dec 09 '22 15:12

Davor