Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Create app with pure Java and no XML?

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

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?

like image 400
Van Coding Avatar asked Nov 07 '11 13:11

Van Coding


People also ask

Can I make Android app using only Java?

Ofcourse you can,most android apps are made of java. Import applet or java swing and you can make what you want.

Is XML necessary for Android development?

We need to implement and define the tags in XML. XML tags define the data and used to store and organize data. It's easily scalable and simple to develop. In Android, the XML is used to implement UI-related data, and it's a lightweight markup language that doesn't make layout heavy.

Is XML required for app development?

Every app project must have an AndroidManifest. xml file (with precisely that name) at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.

Does Android apps use XML?

eXtensible Markup Language, or XML: A markup language created as a standard way to encode data in internet-based applications. Android applications use XML to create layout files. Unlike HTML, XML is case-sensitive, requires each tag be closed, and preserves whitespace.


1 Answers

For the layouts you have two options

  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.

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

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

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

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

like image 184
hovanessyan Avatar answered Sep 20 '22 05:09

hovanessyan