Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10
Accepted Solution

Need help!

Hi 

 

I am phasing problem in the logic.

Here is my code....

 

public MainScreen()

{

ConnectionThread t = new COnnectionThread();

t.start();

}

 

class ConnectionThread extends Thread

{

run()

{

                                //response from url

                               jsonArray

                               {

                                

                                 display( icon,name,place,id)

                             }

}

 

public void display( icon,name,place,id)

{

add(icon);

add(name);

add(place);

// I have made the iconField as Focusable. Now i want when i click the icon i will get the id associated with it.

Earlier i done this by adding the response value into the hashtable and then get it.But this time i want to find a reliable solution to my problem.

}

}

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Need help!

It is not clear to me what you problem is.

 

However your code looks incorrect in that you appear to be trying to update the UI from a background thread.  So this:

 

display( icon,name,place,id);

 

should probably be replaced by

 

UiApplication.get UiApplication().invokeLater(new Runnable() {

public void run() {

display( icon,name,place,id);

}

});

 

If this doesn't help, please explain what your problem is.

Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Need help!

Thanks for the reply Sir

 

Actually the response i am getting from the server is in json format and it contains contains data in array form like icon,name,add,id,etc.

 

Now i want to display the data in list format . So, i have added the icon,name and add in horizontal manager in displayFunction.

 

So i am getting the array 0 data first, the array1,etc.

 

Now the problem is when i click the icon ,its id will be displayed.

But i am getting the last id only.

For Eg:-

 

icon1 name1 add1

---------------------------

icon2 name2 add2

----------------------------

and so on....

When i click on icon1 , i want to retrieve its id i.e id1

When i click on icon2, i want to retrieve id2.

 

But every time i am getting the id of the last array element.If the last json array element id is 41, and i click on icon1 i am getting id as 41.

 

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Need help!

At first glance this would appear to be a logic error in your code when handling the click event associated with the icon.  Since you have not given us the code associated with creating this or responding to the click, I am not sure how you expected us to determine what the problem is.

 

But please don't just post your code.  I suspect a logic error in your code.  Now you wrote this code and so you understand better than anyone lese.  You know how it is supposed to work.  So check your code, debug it, desk check it, review it and then check it again. 

 

When you are convinced your code should work and it is not, then explain carefully how it should work, and what it is doing that does not  match this.  Show us a sample of the icon being added and what happens when you press on it.  We don't need to see the JSON processing, we don't need to see the HFM, we only need the icons so you should be able to mock up a simple test case to demonstrate the problem with just a hard coded array with 3 entries - i.e. you should be able to post just a few lines in one class to demonstrate this problem, using standard BB Fields. 

Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Need help!

Yes Sir

Its a logic error in my code.

Finally i have solved it.

Please use plain text.