简体   繁体   English

从Eclipse Java项目创建Android应用程序

[英]Creating an android app from an Eclipse Java project

I know that questions like this have been asked before, and I have been sifting through them. 我知道之前曾经问过这样的问题,我一直在筛选它们。 So here is my situation: I have a decent amount of experience using Java, specifically Eclipse, and I have a game ready that from my current standards, could be uploaded to the Google marketplace. 所以我的情况就是这样:我有很多使用Java的经验,特别是Eclipse,我准备好了一个游戏,根据我目前的标准,可以上传到谷歌市场。

However, I have the project saved as a Java project. 但是,我将项目保存为Java项目。 How do I make this project into an android app? 如何将此项目变成Android应用程序? I have attempted using the ADT plugin for Ecclipse, and changing the nature of the project file but I am beyond confused regarding how to proceed. 我曾尝试使用Ecclipse的ADT插件,并改变项目文件的性质,但我对如何继续进行操作感到困惑。

Right now I can click: Run < Run as < Java application. 现在我可以单击:运行<Run as <Java application。 The goal is to be able to click: Run < Run as < Android application. 目标是能够单击:运行<运行<Android应用程序。

I don't know of a streamlined way of doing it. 我不知道采用简化的方式。 Is your game using Swing as a UI? 您的游戏是否使用Swing作为UI? JavaFX? JavaFX的? Is it text? 是文字吗?

Regardless, I imagine your game would need to be wrapped in an android activity in some way. 无论如何,我想你的游戏需要以某种方式包含在Android活动中。 eg The activity can invoke the browser to run your applet (if your game is an applet). 例如,活动可以调用浏览器来运行您的applet(如果您的游戏是applet)。

I'd first create an android project, then copy your source from the java project into the android project. 我首先创建一个android项目,然后将你的源码从java项目复制到android项目中。 The manifest (R) will be updated with the new resources, etc. 清单(R)将使用新资源等进行更新。

Then you have to finish wiring everything up. 然后你必须完成所有的连线。

It's going to take more than that. 这将需要更多。 Android has it's own UI system and lifecycle that differs from raw Java. Android拥有自己的UI系统和生命周期,与原始Java不同。 Depending on how you've written the game you may be able to reuse a lot of the drawing and logic code but you going to need to make a lot of changes to the input and allowing multiple screen sizes. 根据您编写游戏的方式,您可以重复使用大量的绘图和逻辑代码,但是您需要对输入进行大量更改并允许多种屏幕尺寸。

Without seeing your code I can say exactly what you'll need to do but I can tell you it's not going to be as simple as Run As... Android Application. 在没有看到你的代码的情况下,我可以确切地说出你需要做什么,但我可以告诉你它不会像Run As ... Android应用程序一样简单。

Although android apps are written in Java code, this doesn't means that it is possible to "translate" a java program or a game in an android app simply clicking a button. 虽然Android应用程序是用Java代码编写的,但这并不意味着只需单击按钮就可以在Android应用程序中“翻译”java程序或游戏。

If the game are complex I suggest that you rewrite the game using a framework for develop android game!! 如果游戏很复杂,我建议你用开发安卓游戏的框架重写游戏! You can reuse some logic but sure you have to create all the graphics and readapt the game to run in android devices. 您可以重复使用某些逻辑,但确定您必须创建所有图形并重新设置游戏以在Android设备中运行。

GOOD WORK!! 好工作!! Be patient and star from here: Androi Developers 请耐心等待,并从这里出演: Androi Developers

It is not possible. 这不可能。 You can implement the application logic in Android in the same way that you used in Java, but you cannot simply convert the java project into Android project. 您可以像在Java中一样在Android中实现应用程序逻辑,但是您不能简单地将Java项目转换为Android项目。 Some packages used in your java project (like swing) can't be used in Android. 你的java项目中使用的一些包(如swing)不能在Android中使用。

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

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