button add function
This commit is contained in:
parent
493804c24d
commit
0c1aca31de
@ -1,7 +1,10 @@
|
|||||||
package org.dnss.sfs.git.wdg.noise
|
package org.dnss.sfs.git.wdg.noise
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.LinearLayout
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.google.android.material.navigation.NavigationView
|
import com.google.android.material.navigation.NavigationView
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
@ -54,4 +57,17 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val navController = findNavController(R.id.nav_host_fragment_content_main)
|
val navController = findNavController(R.id.nav_host_fragment_content_main)
|
||||||
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user