Sorry, double post. On 1 feb, 18:37, David Arm <[email protected]> wrote: > Hi! Im having a problem with a tablelayout. Im trying to add rows > dinamically and display the content of these rows (there are not > content problems as T tested it and the app has all the data that it > needs). > > This is the java code and the xml of the activity: > > [syntax="java"]import java.util.ArrayList; > > import android.app.Activity; > import android.content.Intent; > import android.os.Bundle; > import android.util.Log; > import android.view.View; > import android.view.View.OnClickListener; > import android.widget.Button; > import android.widget.TextView; > > public class DisplayResult extends Activity{ > > /** Called when the activity is first created. */ > > �...@suppresswarnings("unchecked") > public void onCreate(Bundle savedInstanceState) { > > System.out.println("2º actividad lanzada"); > > super.onCreate(savedInstanceState); > setContentView(R.layout.displayresults); > Bundle extras = getIntent().getExtras(); > > //this.setContentView(R.layout.main); > > /* Find Tablelayout defined in main.xml */ > TableLayout tl = (TableLayout)findViewById > (R.layout.displayresults); > > ArrayList finalResults; > > if(extras!=null){ > finalResults = (ArrayList) (extras.getSerializable > (RemoteIR.RESULTS)); > > Iterator it = finalResults.iterator(); > > while(it.hasNext()) { > SearchResult result = ((SearchResult) it.next()); > > /* Create a new row to be added. */ > TableRow tr = new TableRow(this); > tr.setLayoutParams(new LayoutParams( > LayoutParams.FILL_PARENT, > LayoutParams.WRAP_CONTENT)); > > TextView title = new TextView(this); > title.setText(result.title.toString()); > //System.out.println(title.getText()); > > TextView author = new TextView(this); > author.setText(result.author.toString()); > > TextView file = new TextView(this); > file.setText(result.file.toString()); > > TextView modDate = new TextView(this); > author.setText(result.modDate.toString()); > > TextView size = new TextView(this); > size.setText(result.size.toString()); > > title.setLayoutParams(new LayoutParams( > LayoutParams.FILL_PARENT, > LayoutParams.WRAP_CONTENT)); > > author.setLayoutParams(new LayoutParams( > LayoutParams.FILL_PARENT, > LayoutParams.WRAP_CONTENT)); > > file.setLayoutParams(new LayoutParams( > LayoutParams.FILL_PARENT, > LayoutParams.WRAP_CONTENT)); > > modDate.setLayoutParams(new LayoutParams( > LayoutParams.FILL_PARENT, > LayoutParams.WRAP_CONTENT)); > > size.setLayoutParams(new LayoutParams( > LayoutParams.FILL_PARENT, > LayoutParams.WRAP_CONTENT)); > > tr.addView(title); > tr.addView(author); > tr.addView(file); > tr.addView(modDate); > tr.addView(size); > > tl.addView(tr,new TableLayout.LayoutParams( > LayoutParams.FILL_PARENT, > LayoutParams.WRAP_CONTENT)); > > } > > } > > } > > }[/syntax] > > This is the xml: > > [syntax="xml"] > <?xml version="1.0" encoding="utf-8"?> > <TableLayout xmlns:android="http://schemas.android.com/apk/res/ > android" > android:id="@+id/DisplayResults" > android:layout_width="fill_parent" > android:layout_height="fill_parent" > > > > <TableRow> > <TextView > android:layout_column="1" > android:text="Title" > android:padding="3dip" /> > <TextView > android:text="Author" > android:padding="3dip" /> > <TextView > android:text="File" > android:padding="3dip" /> > <TextView > android:text="ModDate" > android:padding="3dip" /> > <TextView > android:text="Size" > android:padding="3dip" /> > </TableRow> > > </TableLayout>[/syntax] > > And this is the error that is frustrating me :s > > ERROR: > > 02-01 12:10:34.129: ERROR/AndroidRuntime(938): Uncaught handler: > thread main exiting due to uncaught exception > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): [b] > java.lang.RuntimeException: Unable to start activity ComponentInfo > {citic.android.remoteir/citic.android.remoteir.DisplayResult}: > java.lang.NullPointerException[/b] > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > android.app.ActivityThread.performLaunchActivity(ActivityThread.java: > 2496) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: > 2512) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > android.app.ActivityThread.access$2200(ActivityThread.java:119) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > android.os.Handler.dispatchMessage(Handler.java:99) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > android.os.Looper.loop(Looper.java:123) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > android.app.ActivityThread.main(ActivityThread.java:4363) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > java.lang.reflect.Method.invokeNative(Native Method) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > java.lang.reflect.Method.invoke(Method.java:521) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run > (ZygoteInit.java:860) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > dalvik.system.NativeStart.main(Native Method) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): Caused by: > java.lang.NullPointerException > [b]02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > citic.android.remoteir.DisplayResult.onCreate(DisplayResult.java:93)[/ > b] > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: > 1047) > 02-01 12:10:34.149: ERROR/AndroidRuntime(938): at > android.app.ActivityThread.performLaunchActivity(ActivityThread.java: > 2459) > > Thank you all in advance! (I hope that someone helps me)[syntax="java"] > [/syntax]
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

