You are not logged in.

#1 2019-05-06 07:40:54

Shivam Bhatele
Member
From: Delhi
Registered: 2019-05-06
Posts: 1
Website

Groovy

How to develop android applications using Groovy? Any suggestions or references?

Offline

#2 2019-05-14 09:28:02

vijaydeveloper
Member
Registered: 2019-05-14
Posts: 1

Re: Groovy

@Shivam_Bhatele;
Follow the below-given steps:
Step 1: Create a new Android project in Android Studio
Step 2: Open this build.gradle (Module: app) file.
Step 3: You will now create an additional “Java Folder” below main. Use New->Folder->Java Folder instead of New->Directory
The name in the entry field is src/main/groovy.
Step 4: Create a new, MainActivity, with the context menu of the groovy folder, and enter the name of this class fully qualified with the package name.
Step 5: MainActivity class can be migrated from .java to .groovy by choosing Refactor->Rename File from the context menu. The file extension .java is simply replaced with a .groovy extension.
Step 6: Give the “Hello World” text view id in the res/layout/activity_main.xml file

Step 7: In MainActivity.groovy, programmatically change the text shown by this view using groovy’s string interpolation:
public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main)
        int id = R.id.textview_hello
        findViewById(id).text = "Hello Groovy"
    }
}
Step 8: Build and execute the application.

To get complete instruction to follow this link and click here for learning tutorials.

Offline

Board footer

Powered by FluxBB