Click here to Skip to main content
15,902,275 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create 10 new button with different name by for loop in run time
:confused:
Posted
Comments
DaveAuld 8-Jan-11 15:35pm    
what language are you programming in with the blackberry?

1 solution

Using the sample code on the blackberry api dev site here.[^]

Java
FieldChangeListener listener = new FieldChangeListener() {
    public void fieldChanged(Field field, int context) {
        ButtonField buttonField = (ButtonField) field;
        System.out.println("Button pressed: " + buttonField.getLabel());
    }
};

for (int x=0; x< 10; x++)
{
    ButtonField buttonField = new ButtonField("Test Button" + x);
    buttonField.setChangeListener(listener);
}


I have never developed on Blackberry, so can't say for sure it 100% correct, but it will give you a starter.
 
Share this answer
 
Comments
farzaneh5 11-Jan-11 13:27pm    
thank you but I couldn't run in c# application and has some error.my application don't know FieldChangeListener so show error. if it doesn't matter and you have enough time first test code and write for me.
DaveAuld 11-Jan-11 13:35pm    
Are you writing C# code? I made a guess considering you used the tag BLACKBERRY, which where i got the Java from looking at the blackbery dev site.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900