Android的 - 创建一个纯Java没有XML的应用程序? [英] Android - Create app with pure Java and no XML?

查看:201
本文介绍了Android的 - 创建一个纯Java没有XML的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能创建一个只Java的Andr​​oid应用程序。没有XML,没有别的东西。

I'm wondering if it is possible to create an Android app with only Java. No XML, no other things.

在Eclipse中,当我创建一个新的Andr​​oid项目,该清单XML文件和主要布局的xml文件自动生成。我可以删除这些文件和一个Java文件代替他们?

In Eclipse, when I create a new Android Project, the Manifest xml-file and the main layout xml-file is automatically generated. Can I delete those files and replace them by a Java-file?

推荐答案

有关你有两个选择布局

  1. 在声明XML UI元素。 Android提供了相对应的视图类和子类,比如那些部件和布局一个简单的XML词汇。

  1. Declare UI elements in XML. Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts.

实例化在运行时布局元素。您的应用程序可以创建视图和一个ViewGroup对象(并操纵它们的属性)编程。

Instantiate layout elements at runtime. Your application can create View and ViewGroup objects (and manipulate their properties) programmatically.

因此​​,对于第一个问题 - 是的 - 你可以删除XML布局文件(如果你必须)

So for the first question - yes - you can delete xml layout files (if you must).

我觉得你不能摆脱manifest.xml..Quoting的:

I think you cannot get rid of the manifest.xml..Quoting:

每个应用程序都必须有一个AndroidManifest.xml文件(其中precisely这个名字)在它的根目录下。

Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory.

这篇关于Android的 - 创建一个纯Java没有XML的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆