I want to implement various functions with kotlin and java!

Introduction ...

This article was written in 6th previous article,

** 7th day of daily article posting for 7 days **

It has become

The code to use is pasted below, but see the article 6 before for the detailed features of this app!

--java version: https://github.com/sato-na/guruwake_java

--kotlin version: https://github.com/sato-na/guruwake_kotlin

↓ This is the main subject of this article ↓

To implement various functions in each language ...

--table of contents--

  1. How to put a string in the code in textView

  2. Implementation of editText and how to receive and delete a string

  3. How to implement listView

How to implement textView and put a string in the code

--For java

TextView textView variable name= findViewById(R.id.textView id);
textView variable.setText(Character string to put);

Example)

ResultActivity.java


TextView resultTxt = findViewById(R.id.result_txt);  //30th line
String rTxt = "";
resultTxt.setText(rTxt);  //Line 49

--For kotlin

textView id.text =Character string to put

Example)

ResultText.kt


var rTxt = ""  //Line 22
result_txt.text = rTxt  //40th line

How to enter the character string is also very different

Implementation of editText and how to receive and delete a string

//Implement editText to receive the entered characters
EditText EditText variable name= findViewById(R.id.editText id);
String variable=editText variable.getText().toString();
//Erase the character string entered in editText
editText variable.getEditableText().clear();

Example)

HowManyActivity.java


//Implement editText to receive the entered characters
EditText groupNumE = findViewById(R.id.group_num_et);  //42nd line
String groupNum = groupNumE.getText().toString();

WhoActivity.java


//Erase the character string entered in editText
EditText memberET = findViewById(R.id.member_et);  //80th line
memberET.getEditableText().clear();  //Line 83

--For kotlin

//Implement editText to receive the entered characters
val/var variable=editText id.text.toString()
//Erase the character string entered in editText
editText id?.text?.clear()

Example)

HowManyActivity.kt


//Implement editText to receive the entered characters
val groupNum = group_num_et.text.toString()  //Line 33

WhoActivity.kt


//Erase the character string entered in editText
member_et?.text?.clear()  //Line 55

It's written a little differently, but the amount of code doesn't change much

How to implement listView

--For java

ListView listView variable name= findViewById(R.id.listView id);
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1,List to put);
listView variables.setAdapter(adapter);

Example)

CheckActivity.java


final ArrayList<String> memberL = new ArrayList(intent.getStringArrayListExtra("MEMBER_L"));  //26th line
ListView memberCheckLV = findViewById(R.id.member_check_lv);  //39th line
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, memberL);
memberCheckLV.setAdapter(adapter);

--For kotlin

val adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1,List to put)
listView id.adapter = adapter

Example)

CheckActivity.kt


val memberL = intent.getStringArrayListExtra("MEMBER_L")  //17th line
val adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, memberL)  //31st line
member_check_lv.adapter = adapter

The writing style is very different, but the amount of code does not change much

Finally…

This time, I implemented various functions with java and kotlin. The code itself is different overall, but the amount of code did not change.

This will end the article posting every day for 7 days! Thank you very much!

Recommended Posts

I want to implement various functions with kotlin and java!
I want to transition screens with kotlin and java!
I want to make a list with kotlin and java!
I want to make a function with kotlin and java!
I want to return to the previous screen with kotlin and java!
Kotlin functions and lambdas to send to Java developers
I want to use java8 forEach with index
I want to display images with REST Controller of Java and Spring!
I will write 5 ways to implement Java Singleton and various advantages and disadvantages
I want to use Clojure's convenient functions in Kotlin
I tried to implement TCP / IP + BIO with JAVA
I tried to implement Stalin sort with Java Collector
I want to get along with Map [Java beginner]
I tried to summarize the basics of kotlin and java
I tried to interact with Java
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
[Java] I want to test standard input & standard output with JUnit
I want to implement it additionally while using kotlin on a site running Java
[Java] I want to perform distinct with the key in the object
I want to perform asynchronous processing and periodic execution with Rail !!!
I want to use DBViewer with Eclipse 2018-12! !!
Kotlin scope functions to send to Java developers
I want to stop Java updates altogether
I tried to implement ModanShogi with Kinx
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (PowerMockito edition)
I want to create a dark web SNS with Jakarta EE 8 with Java 11
I want to ForEach an array with a Lambda expression in Java
[Java] Parse Excel (not limited to various) files with Apathce Tika [Kotlin]
I want to test Action Cable with RSpec test
Run R from Java I want to run rJava
I want to send an email in Java.
Try to link Ruby and Java with Dapr
I tried to implement deep learning in Java
rsync4j --I want to touch rsync in Java.
Getting started with Kotlin to send to Java developers
I want to play with Firestore from Rails
I want to be eventually even in kotlin
Try to implement TCP / IP + NIO with JAVA
I want to write quickly from java to sqlite
I tried to break a block with java (1)
I want to perform aggregation processing with spring-batch
[Rails] I want to load CSS with webpacker
[Kotlin] I wanted to generate a png with a large capacity per area [Java]
I want to control the start / stop of servers and databases with Alexa
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (Javassist second decoction)
I want to play a GIF image on the Andorid app (Java, Kotlin)
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (black magic edition)
Let's create a TODO application in Java 2 I want to create a template with Spring Initializr and make a Hello world
How to call functions in bulk with Java reflection
I tried to implement file upload with Spring MVC
I want to do something like "cls" in Java
I tried to read and output CSV with Outsystems
I tried to implement Firebase push notification in Java
[Java 11] I tried to execute Java without compiling with javac
I want to use ES2015 in Java too! → (´ ・ ω ・ `)
I started MySQL 5.7 with docker-compose and tried to connect
I want to dark mode with the SWT app
I want to monitor a specific file with WatchService
[Java] Refer to and set private variables with reflection
I want to authenticate users to Rails with Devise + OmniAuth
If you want to use Mockito with Kotlin, use mockito-kotlin