Hi rohit, put
dbw.FillData(); TextView col1 = (TextView)findViewById(R.id.col1); TextView col2 = (TextView)findViewById(R.id.col2); after the setContentView(R.layout.displaylog); does it works? On Tue, Apr 7, 2009 at 2:55 AM, rohit.kundal...@gmail.com < rohit.kundal...@gmail.com> wrote: > > I'm trying to display contents of my database on the screen. Its > giving the NullPointerException. I dunno where the problem lies > exactly but seems that there is a problem with setlistadapter... > > Java: > class DataBaseWork extends ListActivity > { > . > . > . > . > . > . > > public void FillData() > { > Cursor c= GetAllRows(); > > > startManagingCursor(c); > ListAdapter adapter = new SimpleCursorAdapter( > this, > R.layout.displaylog, > c, > new String[] {"login_time", "serverIP"}, > new int[] {R.id.col1,R.id.col2} > ); > this.setListAdapter(adapter); > > } > . > . > . > . > > } > > > the 'databasework' is not an activity.. the 'test' class shown below > is the subactivity not the main one.. > > i am calling the filldata() method from 'test' class : > > Java: > public class test extends Activity { > DataBaseWork dbw; > @Override > public void onCreate(Bundle icicle) { > dbw = new DataBaseWork(this); > super.onCreate(icicle); > dbw.FillData(); > > TextView col1 = (TextView)findViewById(R.id.col1); > TextView col2 = (TextView)findViewById(R.id.col2); > > setContentView(R.layout.displaylog); > > > } > > > } > > > cannot figure out what the problem is.. but when i comment out filldata > (), the exception error vanishes.. so the problem lies there i guess.. > hav wasted a lot of time on this.. plz help.. > > here is one of the relevant xml files i am using.. > > XML: > <?xml version="1.0" encoding="utf-8"?> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > android" > android:orientation="vertical" > android:layout_width="fill_parent" > android:layout_height="fill_parent" > > > <TextView id="@+id/col1" > android:layout_width="130sp" > android:layout_height="wrap_content" > android:textSize="10sp" > android:text="Login Time" > /> > <TextView id="@+id/col2" > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:textSize="10sp" > android:text="Server Address" > /> > </LinearLayout> > > Note : I'm still using the very first SDK launched by Google. I find > it convenient and don't have time to change the code to make it > suitable for the latest SDK. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---