简体   繁体   English

Android 仿真器未反映我在.xml 布局文件中所做的更改

[英]The Android emulator is not reflecting changes I have made in .xml layout file

I have re-started Eclipse, re-run the application numerous times, and saved all of my files in my application.我重新启动了 Eclipse,多次重新运行应用程序,并将所有文件保存在我的应用程序中。 In my.xml, I have gotten rid of a button.在 my.xml 中,我去掉了一个按钮。

The.xml is inflated in my.java file. .xml 在 my.java 文件中被夸大了。 However, when I run my application on the Android emulator, it keeps showing the button that I deleted.但是,当我在 Android 模拟器上运行我的应用程序时,它一直显示我删除的按钮。

One possibility is your emulator is not connected to the ADB (Android Debug Bridge)一种可能性是您的模拟器未连接到 ADB(Android 调试桥)

To check just do:检查只是做:

cd C:\Program Files (x86)\Android\android-sdk\platform-tools cd C:\Program Files (x86)\Android\android-sdk\platform-tools

adb devices亚行设备

You should see你应该看到

List of devices attached附加设备列表

emulator-5554 device模拟器 5554 设备

If you don't see this, manually kill the adb.exe process (DON'T kill your emulator).如果您没有看到这一点,请手动终止 adb.exe 进程(不要终止您的模拟器)。

Then manually run adb.exe again.然后再次手动运行 adb.exe。

When you do adb devices you should now see your emulator.当您执行 adb devices 时,您现在应该会看到您的模拟器。 If you close/kill your emulator you may have to repeat the process again.如果您关闭/杀死您的模拟器,您可能需要再次重复该过程。

reinstall the application, clean the project in eclipse.重新安装应用程序,清理 eclipse 中的项目。

OK - I tried all this and it did not work (but I did resolve the problem...).好的 - 我尝试了所有这些但它没有工作(但我确实解决了问题......)。

My project is very simple, as I am a complete newbie and had only created a mock up of the app - a simple interface and adjusted the strings XML file.我的项目非常简单,因为我是一个完整的新手并且只创建了一个应用程序的模型 - 一个简单的界面并调整了字符串 XML 文件。 None the less, I wasted a couple of hours trying to fix this damn problem.尽管如此,我还是浪费了几个小时试图解决这个该死的问题。 In the end, I simply generated a new project and ported all my work over.最后,我只是简单地生成了一个新项目并将我所有的工作移植过来。 This took 10 mins and worked perfectly.这花了 10 分钟,而且效果很好。

To try to learn why this happened, I repreated the steps that seemed to have caused the problem (clearing all projects, and then building them all again) - having copied all the code fromt he original project (including the manifest).为了尝试了解为什么会发生这种情况,我重复了似乎导致问题的步骤(清除所有项目,然后重新构建它们) - 从原始项目中复制了所有代码(包括清单)。 I could not break it again, so am none the wiser about what caused it.我无法再次打破它,所以对造成它的原因一无所知。

A more complicated project might be more of a challenge, but I thought I would post in any case, as I wasted a lot of time trying all these other things without sucess.一个更复杂的项目可能更具挑战性,但我认为无论如何我都会发布,因为我浪费了很多时间尝试所有其他事情而没有成功。

I would have thought that restarting Eclipse would have had the same effect anyway, but for what it's worth, always try Project -> Clean in situations like this.我原以为重新启动 Eclipse 无论如何都会产生相同的效果,但是为了它的价值,在这种情况下总是尝试Project -> Clean

Clean the project and then run.清理项目,然后运行。

The problem happened to me when I imported the project using the orginal files in Eclipse.当我使用 Eclipse 中的原始文件导入项目时,问题发生在我身上。 It worked after I imported the projekt into the eclipse workspace as a copy在我将项目导入 eclipse 工作区作为副本后,它起作用了

I had the same problem in Android Studio.我在 Android Studio 中遇到了同样的问题。 When I added an imageButton it was visible in preview tab of Android Studio, but not in the emulator.当我添加一个imageButton时,它在 Android Studio 的预览选项卡中可见,但在模拟器中不可见。 I tried almost every solution mentioned in Stack Overflow for similar situation, but I didn't succeed.对于类似的情况,我尝试了 Stack Overflow 中提到的几乎所有解决方案,但我没有成功。 One of answers said that you should create a new project and copy your files into it, but this solution had a huge cost for me and I didn't want to try it.其中一个答案说您应该创建一个新项目并将文件复制到其中,但是该解决方案对我来说成本很高,我不想尝试。 Finally I renamed my layout file in the onCreateView method:最后我在onCreateView方法中重命名了我的布局文件:

View view = inflater.inflate(R.layout.fragment_story_edition, container, false);

Then I created a new layout resource and left it empty and ran the project in order to get an error.然后我创建了一个新的布局资源并将其留空并运行项目以获取错误。 After that error, I copied the content of my original layout file to my new made layout file, and the problem was solved.出现该错误后,我将原始布局文件的内容复制到新制作的布局文件中,问题就解决了。

Uninstall the application from Setting->Application->Manage Application->Select Your app->Uninstall.从设置->应用程序->管理应用程序->选择您的应用程序->卸载应用程序。 and then run.It will work然后运行。它会工作

To detail Rasel's answer (in addition to Project...Clean) you can also go to a shell and type adb uninstall com.example.applicationname .要详细说明 Rasel 的答案(除了 Project...Clean),您还可以 go 到 shell 并输入adb uninstall com.example.applicationname

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM