Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Alvinkiang

macrumors newbie
Original poster
Apr 24, 2006
14
0
any one knows how i can let my Transaction Id keep on adding when i click new??
the text1[] ius a loop i used to read out all my textField From XML....

should i insert a Loop or ?

public void New(){

text.setText(item[0]+"\n"+item[1]);
text1[0].setText("");
text1[2].setText("");
text1[4].setText("");
text1[6].setText("");
text1[8].setText("T10001");<----- this is the one...
}
 

jtalerico

macrumors 6502
Nov 23, 2005
358
0
You need something to keep track of how many Transactions have occured. Maybe a transID field. So something along the lines of..

Code:
int transID = 10001;
public void New(){

text.setText(item[0]+"\n"+item[1]);
text1[0].setText("");
text1[2].setText("");
text1[4].setText("");
text1[6].setText("");
text1[8].setText("T"+transID.toString());<----- this is the one...
transID++;
}

Everytime you call that method transID will be added to.. Not sure if that is correct code, not sure what you are using. But it should give you and idea on how to do it.
 

savar

macrumors 68000
Jun 6, 2003
1,950
0
District of Columbia
Wow...what language is this?

I think it would be better if you posted what you're actually trying to accomplish. I suspect you're trying to do something easy the hard way.

Anyway, along the lines of what somebody else said...if you're looking for a way to get unique, sequential integers, you should probably build a separate class to hold that stuff. Keep a private, static integer id in the class and provide a method to fetch the next id. This method will increment the private variable and then return the new value.

Edit: Also, if this is java, then naming a method "New" is a really bad idea.
 

Alvinkiang

macrumors newbie
Original poster
Apr 24, 2006
14
0
savar said:
Wow...what language is this?

I think it would be better if you posted what you're actually trying to accomplish. I suspect you're trying to do something easy the hard way.

Anyway, along the lines of what somebody else said...if you're looking for a way to get unique, sequential integers, you should probably build a separate class to hold that stuff. Keep a private, static integer id in the class and provide a method to fetch the next id. This method will increment the private variable and then return the new value.

Edit: Also, if this is java, then naming a method "New" is a really bad idea.

thanks... i have managed to solve my Problem.. anyway in this func. i was trying to reset my textfeild and at the same time adding on to the next transaction ID
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.