Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't Edit Files in Android Studio

For some unknown reason, I can't edit files in Android Studio. This includes both Java and XML files.

When I launch Android Studio (v1.2.2), everything is fine. However, after some time, I lose the ability to edit files content. Here is what I noticed:

  • When I click on any line in the source code, the lines get highlighted but the caret indicator is not showing.
  • When I start typing, a search for: box starts appearing on the top of the left panel (Project window), and it starts filtering the project files according to what I type!
  • Files are not locked as Read-Only. I checked.
  • Restarting Android Studio did not resolve it permanently. Everything seems fine for some time, then the problem appears again.
  • I did check my keyboard to see if I have a stucked keystroke that might cause this problem. Didn't notice anything.
  • In the Project window, I noticed that MainActivity file name is in grey (See the screenshot below). I'm not sure if this is because of something I did, or if it is how Android Studio identifies the main Activity in the project.

Project View Screenshot

like image 569
iTurki Avatar asked Jul 29 '15 10:07

iTurki


People also ask

Can not write code in Android Studio?

The problem faced has been solved by reverting Android Studio to its default settings. Show activity on this post. I was facing this exact same problem. I solved it by pressing the Insert key once—apparently, I had inadvertently toggled Insert/Overwrite mode, and that was preventing me from editing code.

Can I edit XML files Android?

In Android Studio, you will see all the projects's XML files and can edit them with all the tools Android Studio provides, including the visual designers. As you make changes and save them in Android Studio, they will automatically reflect back into your Elements project inside Visual Studio.


2 Answers

This appears to be that the Code view loses focus to the Project view. That's why I can't edit the code and the search box appears: because The focus is with the Project view, permanently.

I couldn't find a permanent solution. However, by accident, I found a workaround that is less annoying than restarting Android Studio:

When you lose focus to the Project view, click on the far right of the Code View, where the scrollbar exist.

I tried to figure out what causes the Project View to steal the focus permanently but I couldn't. Until someone do, this will be the accepted answer.

like image 170
iTurki Avatar answered Oct 24 '22 14:10

iTurki


click on vertical scroll bar area to get focus in project view

click on vertical scroll bar area to get focus in project view

like image 26
Divyanshu Jimmy Avatar answered Oct 24 '22 14:10

Divyanshu Jimmy