Pure Java and Android App

Asked

Viewed 533 times

11

I’m a beginner in Java. I preferred to start studying pure Java, that is, I discarded studying by dragging components. I met Javafx; I preferred to study the construction of these components at hand as well. I learned many things, many even. I made some applications for desktop, but did not like the difficulty in security and sale of these applications; so decide to start making apps for Android.

My questions are:

How to use my knowledge of Java and Javafx on Android?

For example, I learned to navigate between screens in very interesting ways, but on Android, it will matter?

In other words, you can program on Android in a pure way, without having to drag components all the time?

  • Don’t confuse Android with Android Studio (IDE).

3 answers

7

If you already know/have knowledge in Java, will have more ease with Android, since in Android Studio you will work with java.. (You can also develop using C# and Javascript).

Regarding the interfaces, in Android, they are XML files. Then, you can either drag the components and position them where needed or create them using only the codes.

For example: You can drag the components to create the screen
Tela arrastando os componentes

Or else, you can write all the xml. For the above example, it would look like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10" >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/configuracoes" />

</LinearLayout>

I’ll leave here some references for study:

Android Developer

Book: Google Android - Edition 4

Book: Google Android: Create apps for mobile phones and tablets

  • But I usually create buttons, label etc... in pure java, not xml; it would be unnecessary to make these components that way, since you can just drag.

  • @Carlosximendes, there is the possibility to drag, I believe it is a matter of taste do in hand or drag

7

The development Android, allows you to "drag" the components to the screen, I particularly do not like to do this,but the development of screens on android is very intuitive.

How to use my knowledge of Java and Javafx on Android?

The native android development is done through the Java language so what you learned you can apply easily, in Javafx we put actions for the buttons:

myNode.setOnMouseClicked(new EventHandler<MouseEvent>()

In android there is an almost identical way where we can add a method in our buttons in the same way

btEntrar.setOnClickListener(new View.OnClickListener()

For example, I learned to navigate between screens in very interesting ways, but on Android, it will matter?

Again Android studio is just an IDE, in android navigation between screens are made through INTENTS, where you create an intention to launch the new screen through some event or success in data validation.

In other words, you can program on Android in a pure way, without having to drag components all the time?

As I mentioned in the first question it is possible yes you create your layouts and within them you can put in your hand every component you want or do this by programming directly in Java.

Example of some known components:

Edittext : displays a field for the user to enter values it is possible to define attributes for the same, such as allowing only numbers or text, size, colors among others.

Button: Displays a button for the user, it has several properties that can be worked easily.

Textview: Works like a label

The books that emanuelsn mentioned are very didactic and can help you in this stage of adaptation, here at Sopt we also have several questions already answered related to tag Android.

Component palette in Android Studio

inserir a descrição da imagem aqui

To use just expand and drag the desired component.

Documentation

  • 1

    I like to drag the components and then go and edit as I want. ;)

  • haha, I no longer like it gets all played on the screen, hahaha

0

Look, actually your knowledge in java will count a lot, you have to have some knowledge of concepts like object orientation. I advise first to read about life cycle and threads for Android.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.