How to Creat a dynamic button ???

icqrx

New Member
Please help me !
I have a idea,
there are 2 editText (Enter weight and hight of button) and one button with name "Creat Button". When I click "Creat Button", program automatic creat a new button with weight and hight to EditText. Change value to EditText, click "CreatButton", => size of button change! Done!
Sorry, I come from VietNam, my English not good. can you help me demo code example? Thanks all!:(
 
Last edited:
all views can be created at runtime, except for the main activity... So, look for the .initialize and .addview parameter's they are self explanatory
 
Upvote 0
Dynamic Button

Please help me !
I have a idea,
there are 2 editText (Enter weight and hight of button) and one button with name "Creat Button". When I click "Creat Button", program automatic creat a new button with weight and hight to EditText. Change value to EditText, click "CreatButton", => size of button change! Done!
Sorry, I come from VietNam, my English not good. can you help me demo code example? Thanks all!:(

Hi icqrx,

Look this.

Sub Process_Globals
End Sub
Sub Globals
Dim lst As List
End Sub
Sub Activity_Create(FirstTime As Boolean)

Dim i As Int

Dim panels As Panel
panels.Initialize("panels")
panels.color = Colors.Gray

lst.Initialize

For i = 0 To 1
Dim edt As EditText
edt.Initialize("")
edt.Color = Colors.Green
edt.Text = "Here"

lst.Add(edt)
panels.AddView(edt, 10dip, 90dip, 300dip, 200dip)

Next

Dim btn As Button
btn.Initialize("Button")
btn.Text="Create Button"
btn.Tag = "Create Button"
panels.AddView(btn,10%x,10%y,50%x,20%x)

Activity.AddView(panels, 0, 0, 100%x, 100%y)

End Sub
Sub Button_Click

Dim i As Int

For i = 0 To lst.Size - 1
Dim edt As EditText
edt = lst.Get(i)

edt.Text = "Create Button " & i
Next

End Sub
 
Upvote 0
This is a Basic forum and not a Java forum.
Two products:
- Basic4PPC this is for Windows Mobile 6.6 and below
- Basic4Android, a Basic language to write Android applications.

The code in post #3 is Basic4Android code !
If you are looking for Java code you'r in a wrong forum.

Best regards.
 
Upvote 0
Back
Top