Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

list view problem

 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic