This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Android and the fly likes list view problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "list view problem" Watch "list view problem" New topic
Author

list view problem

Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

Hello ranchers,
I have a layout with 2 editboxes,a button and a listview. The user fills in some data to the editboxes, and presses the button. I call a .NET webservice that returns data , in json format. I want to fill the listview with the data from the web service. I created a custom adapter and a listitem layout but i get the data but they dont display on the screen. any ideas why??

thanks in advance..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41033
    
  43
i get the data but they dont display on the screen. any ideas why?

No. Did you mean to post the code that you think should display the data? Without seeing that, I don't think any of us are in a position to even guess at the problem.


Ping & DNS - my free Android networking tools app
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

good morning,
this is my code oncreate function


i populate 2 custom objects and fill a list. this list i pass it to my custom adapter and fill the listview. below is my custome adapter


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41033
    
  43
You're not adding two objects to the list, you're adding the same object twice - that will most likely lead to the data assigned first (OfeilID=1) to be lost.

Is the code in the "if (ofeil != null)" block in the getView method being executed?

(I removed the other method from your post, as it's not relevant to the problem at hand.)
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

yes it if statment is executing ok. the object isnt null. i am adding 2 objects to a object list.
this is the error message
02-11 09:36:30.522: ERROR/AndroidRuntime(443): FATAL EXCEPTION: main
02-11 09:36:30.522: ERROR/AndroidRuntime(443): android.content.res.Resources$NotFoundException: String resource ID #0x2
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.content.res.Resources.getText(Resources.java:201)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.TextView.setText(TextView.java:2817)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at com.minosnet.dimarxos.oikonomiki.filterOfeiletesMaster$OfeiletesAdapter.getView(filterOfeiletesMaster.java:121)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.AbsListView.obtainView(AbsListView.java:1315)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.ListView.makeAndAddView(ListView.java:1727)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.ListView.fillDown(ListView.java:652)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.ListView.fillFromTop(ListView.java:709)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.ListView.layoutChildren(ListView.java:1580)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.AbsListView.onLayout(AbsListView.java:1147)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.view.View.layout(View.java:7035)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.view.View.layout(View.java:7035)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.view.View.layout(View.java:7035)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.view.View.layout(View.java:7035)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.view.View.layout(View.java:7035)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.os.Handler.dispatchMessage(Handler.java:99)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.os.Looper.loop(Looper.java:123)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at java.lang.reflect.Method.invokeNative(Native Method)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at java.lang.reflect.Method.invoke(Method.java:521)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-11 09:36:30.522: ERROR/AndroidRuntime(443): at dalvik.system.NativeStart.main(Native Method)

one question this class extends Activity, i tried to extend it to listactivity but with the same result..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41033
    
  43
i am adding 2 objects to a object list.

No, you're not - you're adding two references to the same object. You're not even creating two objects.

I suggest to do a clean build, it seems Android is getting confused over some aspect of the layout.
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

i tried out a clean build but i get the same error. this is my layout for the activity


and this is my item layout for the list.


cant understand why i get this error...
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

OK found the problem. i was passing an int to a textview and it was throwing an error there. found it out of luck trying different stuff. thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: list view problem
 
Similar Threads
Refreshing jQuery Mobile listviews
Question on ListView
How to control scroll bars upto listview height.
How to add button at the end of the screen (after the ListView)
regarding layout