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 ↓
--table of contents--
How to put a string in the code in textView
Implementation of editText and how to receive and delete a string
How to implement listView
--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
//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
--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
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