button add function

This commit is contained in:
Specoolazius 2021-06-28 15:28:55 +02:00
parent 493804c24d
commit 0c1aca31de

View File

@ -1,7 +1,10 @@
package org.dnss.sfs.git.wdg.noise
import android.graphics.Color
import android.os.Bundle
import android.view.Menu
import android.widget.Button
import android.widget.LinearLayout
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.navigation.NavigationView
import androidx.navigation.findNavController
@ -54,4 +57,17 @@ class MainActivity : AppCompatActivity() {
val navController = findNavController(R.id.nav_host_fragment_content_main)
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
}
fun addButton(text: String) {
val dynamicButton = Button(this)
dynamicButton.layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
dynamicButton.text = "Dynamic Button"
dynamicButton.setBackgroundColor(Color.GREEN)
// add Button to LinearLayout
//linearLayout.addView(dynamicButton)
}
}