Hi its starting at onCreate i think , this is what logcat shows.
02-02 21:49:05.414: ERROR/AndroidRuntime(704): Uncaught handler:
thread main exiting due to uncaught exception
02-02 21:49:05.434: ERROR/AndroidRuntime(704):
java.lang.RuntimeException: Unable to start activity ComponentInfo
{project.Maps/project.Maps.SatMain}: java.lang.NullPointerException
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2268)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
android.app.ActivityThread.access$1800(ActivityThread.java:112)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
android.os.Handler.dispatchMessage(Handler.java:99)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
android.os.Looper.loop(Looper.java:123)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
android.app.ActivityThread.main(ActivityThread.java:3948)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
java.lang.reflect.Method.invokeNative(Native Method)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
java.lang.reflect.Method.invoke(Method.java:521)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
dalvik.system.NativeStart.main(Native Method)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): Caused by:
java.lang.NullPointerException
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
project.Maps.SatMain.onCreate(SatMain.java:68)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)
02-02 21:49:05.434: ERROR/AndroidRuntime(704): ... 11 more
I have no idea how to fix this? Can you help please.
On Feb 2, 4:36 am, Justin Anderson <[email protected]> wrote:
> Can you give us a little more info, like where the NullPointerException
> happens in the code?
>
> ----------------------------------------------------------------------
> There are only 10 types of people in the world...
> Those who know binary and those who don't.
> ----------------------------------------------------------------------
>
> On Mon, Feb 1, 2010 at 3:09 PM, Sam B <[email protected]> wrote:
> > Hi guys im trying to put a button on each row of a list but i get null
> > pointer exception, i'll show the java files below. The list view is in
> > a seperate xml file to the button because button is inside a relative
> > layout. Can anyone help?.
>
> > This class gets data from a database and puts it in array and displays
> > in a list view which works fine until i try to put a button in each
> > row.
> > Java:
>
> > package project.Maps;
> > public class SatMain extends Activity {
> > /** Called when the activity is first created. */
> > ArrayList<String> results = new ArrayList<String>();
> > @Override
> > public void onCreate(Bundle savedInstanceState)
> > {
> > super.onCreate(savedInstanceState);
> > setContentView(R.layout.main);
> > dbAdapter db = new dbAdapter(this);
>
> > ;
>
> > //---get all titles---
> > db.open();
> > db.InsertData();
>
> > Cursor c = db.getSat1();
>
> > if (c.moveToFirst())
> > {
> > do {
> > String pub = c.getString(c.getColumnIndex
> > (db.KEY_Artist));
> > String pub1 = c.getString(c.getColumnIndex
> > (db.KEY_Time));
>
> > results.add(pub + pub1 );
> > } while (c.moveToNext());
> > }
> > db.close();
>
> > ListView listProducts;
> > List<String> results = new ArrayList<String>();
> > Context cont = null;
> > customArray ca = new customArray(cont, R.layout.button,
> > results);
> > listProducts = (ListView)findViewById(R.id.list123);
> > listProducts.setAdapter(ca);
> > ca.notifyDataSetChanged();
> > }}
>
> > Code for my custom adapter.
>
> > Java:
>
> > package project.Maps;
> > import java.util.List;
> > public class customArray extends ArrayAdapter<String> {
> > int resource;
>
> > public customArray(Context cont, int _resource, List<String>
> > results) {
> > super (cont, _resource, results);
> > resource = _resource;
> > }
>
> > @Override
> > public View getView(int position, View convertView, ViewGroup
> > parent) {
> > RelativeLayout rl;
>
> > // String prod = getItem(position);
> > if (convertView == null) {
> > rl = new RelativeLayout(getContext());
> > LayoutInflater vi = (LayoutInflater)getContext
> > ().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
> > vi.inflate(resource, rl, true);
> > } else {
> > rl = (RelativeLayout)convertView;
> > }
>
> > return rl;
> > }
> > }
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Beginners" group.
>
> > NEW! Try asking and tagging your question on Stack Overflow at
> >http://stackoverflow.com/questions/tagged/android
>
> > To unsubscribe from this group, send email to
> > [email protected]<android-beginners%[email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-beginners?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en