From 3afa5dd7f0e7b72cd8ca4a878176681511d5db42 Mon Sep 17 00:00:00 2001 From: Specoolazius Date: Mon, 28 Jun 2021 16:32:06 +0200 Subject: [PATCH] button adding --- .../dnss/sfs/git/wdg/noise/MainActivity.kt | 20 +++++++++++++------ app/src/main/res/layout/content_main.xml | 16 +++++++++++++++ app/src/main/res/values/colors.xml | 1 + 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/dnss/sfs/git/wdg/noise/MainActivity.kt b/app/src/main/java/org/dnss/sfs/git/wdg/noise/MainActivity.kt index 7c0f6b6..2fb3485 100644 --- a/app/src/main/java/org/dnss/sfs/git/wdg/noise/MainActivity.kt +++ b/app/src/main/java/org/dnss/sfs/git/wdg/noise/MainActivity.kt @@ -45,6 +45,11 @@ class MainActivity : AppCompatActivity() { ) setupActionBarWithNavController(navController, appBarConfiguration) navView.setupWithNavController(navController) + + addButton( "a", 0xff0000) + addButton( "b", 0xff0000) + addButton( "c", 0xff0000) + addButton( "d", 0xff0000) } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -58,16 +63,19 @@ class MainActivity : AppCompatActivity() { return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp() } - fun addButton(text: String) { + fun addButton(userName: String, color: Int) { + val contactScrollField = findViewById(R.id.linear_layout) + // = findViewById(R.id.linear_layout) as LinearLayout + val dynamicButton = Button(this) - dynamicButton.layoutParams = LinearLayout.LayoutParams( + /*dynamicButton.layoutParams = LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT - ) - dynamicButton.text = "Dynamic Button" + )*/ + dynamicButton.text = userName dynamicButton.setBackgroundColor(Color.GREEN) - // add Button to LinearLayout - //linearLayout.addView(dynamicButton) + + contactScrollField.addView(dynamicButton) } } \ No newline at end of file diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index 6e0ea39..63c598a 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -17,4 +17,20 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:navGraph="@navigation/mobile_navigation" /> + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index ce92792..20952f5 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -7,4 +7,5 @@ #FF018786 #FF000000 #FFFFFFFF + #00FF0090 \ No newline at end of file