tags:

views:

90

answers:

2

Im guessing my buttons are right, but when clicked they add integers on the compiler and subtract integers using the next and previous buttons. i want them to scroll through the contacts on the file i have connected?

    public void nextContact()
    {

       if(index < details.size() - 1)               
       {           

            index++; 
            System.out.println(index);

            txtname.setText(name.get(index));                
            txtnum.setText(phone.get(index));               
            txtmob.setText(mobile.get(index));               
            txtadd1.setText(address.get(index));            
       }                
       importContacts();
    }

    public void prevContact()
    {
    if (index > 0)               
     {                       
           index--;  
           System.out.println(index);

            txtname.setText(name.get(index));                
            txtnum.setText(phone.get(index));               
            txtmob.setText(mobile.get(index));               
            txtadd1.setText(address.get(index));               
     }                

     importContacts();

    }
+1  A: 

I'm gonna guess you mean

  • the buttons "Print integers on the commandline / console" instead of "add integers on the compiler".
  • and "the User interface is not updated" instead of "buttons do not interact with the GUI"

To solve the first problem remove or comment out the System.out.println(index) statements.

To solve the second problem we'd need to know what kind of GUI you're building, and see if and where you tell the GUI to update..

Tim
A: 

This question make me think to this one .

So I think it's because each time nextContact() and previousContact() are executed, you re-import all your contact via importContact().

Importing contacts shouldn't be done each time you click on your next or previous button. Probably in your importContact(), you have something like that.

txtname.setText(0);                
txtnum.setText(0);               
txtmob.setText(0);               
txtadd1.setText(0);
Nettogrof