Well, that might be it... Were you getting the data before when you couldn't get the button to display though?
---------------------------------------------------------------------- There are only 10 types of people in the world... Those who know binary and those who don't. ---------------------------------------------------------------------- On Tue, Feb 2, 2010 at 5:30 PM, Sam B <[email protected]> wrote: > Shall i post my xml files? Or maybe it is the custom array not getting > the data from the db? > > On Feb 3, 12:21 am, Sam B <[email protected]> wrote: > > Yea im doing it via Xml the button layout code is wrap_content so im > > not sure why this isnt working. > > > > On Feb 2, 11:58 pm, Justin Anderson <[email protected]> wrote: > > > > > Are you defining layouts via XML? If so, a common culprit is to have > > > layout_width="fill_parent" or layout_height="fill_parent" (depending on > > > orientation) when you really want wrap_content. > > > > > ---------------------------------------------------------------------- > > > There are only 10 types of people in the world... > > > Those who know binary and those who don't. > > > ---------------------------------------------------------------------- > > > > > On Tue, Feb 2, 2010 at 4:37 PM, Sam B <[email protected]> > wrote: > > > > Woo , i fixed the problem now i can get a button on each row . > > > > However still one small problem before i had the list view populated > > > > with data from my database , now that ive added a button to each row > > > > the data has disappeared. > > > > > > On Feb 2, 10:57 pm, Sam B <[email protected]> wrote: > > > > > 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]> > <android-beginners%[email protected]<android-beginners%[email protected]> > > > > > > <android-beginners%[email protected]<android-beginners%[email protected]> > <android-beginners%[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]<android-beginners%[email protected]> > <android-beginners%[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]<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

