Re: [android-developers] Re: How to: Free to Paid App and retain preference and db files?
Hi, I want to ask something about LVL. From my brief understanding, LVL add additional code to check back with Google Play server and refuse to run if it was not a paid version. Is there possibility to have the check in Google Play server and not allow user to update if the copy installed is not a purchase version? This way, developer don't have to include LVL code in every app publish. Of course in-app billing is not applicable. On Sunday, 1 July 2012 15:05:28 UTC+8, Dianne Hackborn wrote: On Sat, Jun 30, 2012 at 9:17 AM, Mystique wrote: I was also thinking to write a simple app that generate hash value and write it in a file, user will purchase this app and my main app will look for this file and compare the hash value. Will this work? Does Google allow this? The are two separate apps, so they run under different uids, so can't generally share files. You could do hacks with putting the file to a location on external storage where app permissions are not enforced, but a content provider would be the more formally correct way to do this -- it allows you to have security between the two (protecting the provider with a signature-only permission) and guarantee things like no other applications being able to get in the middle and manipulate the data that is transferred. Definitely don't use shared user IDs just for this. To be honest, I think this is a great example of where in-app billing work well, instead of needing to have two different versions of an app. Just be sure to use the kind of billing product that persists with the user's account. :) -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to: Free to Paid App and retain preference and db files?
Hi, good to learn from all of you here. One of the usual request for the paid version is to remove ads and Internet permission. Some user just do no feel good about turning on Internet permission. If I implement in-app billing, the Internet permission will still be there since it already has it in Manifest so user would not be happy. Having a separate install file/key will still have the same situation. Next option is to add an export feature to the Free app like that Treking suggested so user can export it and import it in the Paid version. This is a good option but I am worried about user uninstalling the free app after purchase and thought the configuration and db will be automatically available. They might not even update to the latest free version that has the export feature. I was evening thinking to automate it in this way if the free app detected the paid app running during start to automatically backup the configure and put it in a sdcard location and when user start the paid version it prompt manually whether to import it if the preference has not been set or option in the menu for import. Then, if user uninstall the free version immediately after installing the paid version then the user will lost the ability to export. Do all these sounds complicated? Do you guys also implement LVL for paid app? If so, do we need to maintain a free version without the LVL code? On Sunday, 1 July 2012 15:05:28 UTC+8, Dianne Hackborn wrote: On Sat, Jun 30, 2012 at 9:17 AM, Mystique wrote: I was also thinking to write a simple app that generate hash value and write it in a file, user will purchase this app and my main app will look for this file and compare the hash value. Will this work? Does Google allow this? The are two separate apps, so they run under different uids, so can't generally share files. You could do hacks with putting the file to a location on external storage where app permissions are not enforced, but a content provider would be the more formally correct way to do this -- it allows you to have security between the two (protecting the provider with a signature-only permission) and guarantee things like no other applications being able to get in the middle and manipulate the data that is transferred. Definitely don't use shared user IDs just for this. To be honest, I think this is a great example of where in-app billing work well, instead of needing to have two different versions of an app. Just be sure to use the kind of billing product that persists with the user's account. :) -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to: Free to Paid App and retain preference and db files?
Yes, I have additional features for the paid version but was thinking to maintain the Ads in the free version. So you are suggestion to completely remove the Ads for free and focus on the Paid version for incentive? On Sunday, 1 July 2012 20:56:37 UTC+8, Kostya Vasilyev wrote: Regarding the Internet permission - you don't have to use ads in the free version, rather offering the users some other incentive(s) to upgrade. 2012/7/1 Mystique Hi, good to learn from all of you here. One of the usual request for the paid version is to remove ads and Internet permission. Some user just do no feel good about turning on Internet permission. If I implement in-app billing, the Internet permission will still be there since it already has it in Manifest so user would not be happy. Having a separate install file/key will still have the same situation. Next option is to add an export feature to the Free app like that Treking suggested so user can export it and import it in the Paid version. This is a good option but I am worried about user uninstalling the free app after purchase and thought the configuration and db will be automatically available. They might not even update to the latest free version that has the export feature. I was evening thinking to automate it in this way if the free app detected the paid app running during start to automatically backup the configure and put it in a sdcard location and when user start the paid version it prompt manually whether to import it if the preference has not been set or option in the menu for import. Then, if user uninstall the free version immediately after installing the paid version then the user will lost the ability to export. Do all these sounds complicated? Do you guys also implement LVL for paid app? If so, do we need to maintain a free version without the LVL code? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Is there sqlite statement to delete first 5 rows?
Hi, let's say I want to delete top 5 rolls of data from the table. I can do a while loop with an counter call i and use cursor.moveToPosition(i) to move to the row and delete it. Is there a better way to do that? Thanks. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Is there sqlite statement to delete first 5 rows?
Ok, make sense. Understood now. Thanks. On Sunday, 1 July 2012 22:56:22 UTC+8, RichardC wrote: SQL statements are set based. By this I mean that unless you order the data in the query SQL does not have to return the data in the same order each time to make the same call. If I assume that you have an ID column which you can order on the the following will work (when you remove any typos I make): DELETE FROM my-table WHERE my-table.id IN (SELECT id FROM my-table ORDER BY id LIMIT 5) On Sunday, July 1, 2012 3:44:23 PM UTC+1, Mystique wrote: Hi, let's say I want to delete top 5 rolls of data from the table. I can do a while loop with an counter call i and use cursor.moveToPosition(i) to move to the row and delete it. Is there a better way to do that? Thanks. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Calling sub-class getCursor() from main class problem
Hi I have this in my method calling getCursor() and is working ok within the class. Now I try to call the method from the main class to perform some routine and receive error: Cannot make a static reference to the non-static method getListAdapter() from the type ListActivity So I changed from: Class B: Cursor cursor = ((CursorAdapter) getListAdapter()).getCursor(); Change to: Cursor cursor = ((CursorAdapter) ((ListActivity) mainContext).getListAdapter()).getCursor(); I can run and execute what I want in class B but if I call it outside in the main class I can't get the result. No warning, nothing. What is wrong? Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Calling sub-class getCursor() from main class problem
Hi I have this in my method calling getCursor() and is working ok within the class. Now I try to call the method from the main class to perform some routine and receive error: Cannot make a static reference to the non-static method getListAdapter() from the type ListActivity So I changed from: Class B: Cursor cursor = ((CursorAdapter) getListAdapter()).getCursor(); Change to: Cursor cursor = ((CursorAdapter) ((ListActivity) mainContext).getListAdapter()).getCursor(); I can run and execute what I want in class B but if I call it outside in the main class I can't get the result. No warning, nothing. What is wrong? Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Calling sub-class getCursor() from main class problem
Hi I have this in my method calling getCursor() and is working ok within the class. Now I try to call the method from the main class to perform some routine and receive error: Cannot make a static reference to the non-static method getListAdapter() from the type ListActivity So I changed from: Class B: Cursor cursor = ((CursorAdapter) getListAdapter()).getCursor(); Change to: Cursor cursor = ((CursorAdapter) ((ListActivity) mainContext).getListAdapter()).getCursor(); I can run and execute what I want in class B but if I call it outside in the main class I can't get the result. No warning, nothing. What is wrong? Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Cannot populate List call from Main Class to Sub Class
Hi, I try to explain my problem hope someone can help me point out the causes. I have a TabActivity that has 2 Tabs MainApp.java and MethodB.java. MethodB has code to populate a List, MainApp also populate the same content but filter out some column so from MainApp I call the method MethodB.Test(String). I cannot get the list populated. If I tab on Tab MethodB first and return to MainApp Tab I got the list content correctly display in MainApp. -MainApp.java-- /* If I call Test(String) in MainApp (MethodB.Test(String), the listview is empty, if the list has been preciously initialise in MethodB not calling from MapApp, the list is populated and if I call Test(String) now in MainApp the list is good. */ -MethodB.java-- /* The Test(String) can correctly populate InitialiseListView */ private static void InitialiseListView() { events = new PasswordEventsData(mainContext); try { Cursor cursor = getEvents(); showEvents(cursor); } finally { events.close(); } } private static Cursor getEvents() { //Perform a managed query. The Activity will handle closing //and re-querying the cursor when needed. SQLiteDatabase db = events.getReadableDatabase(); Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null, null, ORDER_BY); ((Activity) mainContext).startManagingCursor(cursor); return cursor; } private static void showEvents(Cursor cursor) { //Set up data binding SimpleCursorAdapter adapter = new SimpleCursorAdapter(mainContext, R.layout.itemname, cursor, FROM, TO); ((ListActivity) mainContext).setListAdapter(adapter); adapter.notifyDataSetChanged(); } public static void Test(String Type) { InitialiseListView(); } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to: Free to Paid App and retain preference and db files?
Hi, I have a Ads supported app and I am planning to release a paid version without Ads and extra features. My questions are how do I release the app so my user can purchase and use with losing the preferences and db? Can I package it with the same name and upload into Google Play as new app or how is it been normally done? Cheers. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] How to: Free to Paid App and retain preference and db files?
Hi Fred, That is good to know. So Google play don't care if 2 Apps has the same apk/com.my.app is that right? Thanks. On Saturday, 30 June 2012 17:22:37 UTC+8, Fred Niggle wrote: as long as the .apk has the same name, i.e. com.my.app, then you wont lose the preferences and database. If the.apk is different then you will need to consider how to export the sharedprefs/db from the current version (an update), to the sdcard, and have an import function in the newer version. Hope this helps, Fred On 30 June 2012 10:01, Mystique joven.ch...@gmail.com wrote: Hi, I have a Ads supported app and I am planning to release a paid version without Ads and extra features. My questions are how do I release the app so my user can purchase and use with losing the preferences and db? Can I package it with the same name and upload into Google Play as new app or how is it been normally done? Cheers. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Magnetic Door Alarm apphttps://play.google.com/store/apps/details?id=com.nds.magneticdooralarmis now available in Google Play -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to: Free to Paid App and retain preference and db files?
Hi, yes I will consider in app purchase if that is the only option. So am I right to say some free and paid app actually release 2 versions which Google play see it as separate app and each app have their own data directory? On Saturday, 30 June 2012 23:34:56 UTC+8, RichardC wrote: Have you considered using in-app-purchasing to turn off the ads and unlock the extra features? On Saturday, June 30, 2012 10:01:11 AM UTC+1, Mystique wrote: Hi, I have a Ads supported app and I am planning to release a paid version without Ads and extra features. My questions are how do I release the app so my user can purchase and use with losing the preferences and db? Can I package it with the same name and upload into Google Play as new app or how is it been normally done? Cheers. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to: Free to Paid App and retain preference and db files?
I was also thinking to write a simple app that generate hash value and write it in a file, user will purchase this app and my main app will look for this file and compare the hash value. Will this work? Does Google allow this? On Sunday, 1 July 2012 00:02:54 UTC+8, Mystique wrote: Hi, yes I will consider in app purchase if that is the only option. So am I right to say some free and paid app actually release 2 versions which Google play see it as separate app and each app have their own data directory? On Saturday, 30 June 2012 23:34:56 UTC+8, RichardC wrote: Have you considered using in-app-purchasing to turn off the ads and unlock the extra features? On Saturday, June 30, 2012 10:01:11 AM UTC+1, Mystique wrote: Hi, I have a Ads supported app and I am planning to release a paid version without Ads and extra features. My questions are how do I release the app so my user can purchase and use with losing the preferences and db? Can I package it with the same name and upload into Google Play as new app or how is it been normally done? Cheers. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to: Free to Paid App and retain preference and db files?
Right, I have import/export features but only available in the plan paid version :) that's why. On Sunday, 1 July 2012 00:11:04 UTC+8, James Black wrote: You can also allow them to export and import the data, to move from the free to paid version. On Jun 30, 2012 12:03 PM, Mystique joven.ch...@gmail.com wrote: Hi, yes I will consider in app purchase if that is the only option. So am I right to say some free and paid app actually release 2 versions which Google play see it as separate app and each app have their own data directory? On Saturday, 30 June 2012 23:34:56 UTC+8, RichardC wrote: Have you considered using in-app-purchasing to turn off the ads and unlock the extra features? On Saturday, June 30, 2012 10:01:11 AM UTC+1, Mystique wrote: Hi, I have a Ads supported app and I am planning to release a paid version without Ads and extra features. My questions are how do I release the app so my user can purchase and use with losing the preferences and db? Can I package it with the same name and upload into Google Play as new app or how is it been normally done? Cheers. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Disable search button press during ProgressDialog
I have a simple ProgressDialog but I realized if I press the search button the dialog will be dismiss. What can I do to disable search button press during this process? dialog = new ProgressDialog(Main.this); dialog.setTitle(Working in progress); dialog.setMessage(Please wait...); dialog.setCancelable(false); dialog.show(); I add a setOnKeyListener but it is still now working. dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH event.getRepeatCount() == 0) { return true; // Pretend we processed it } return false; // Any other keys are still processed as normal } }); -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Disable search button press during ProgressDialog
This do not work too. dialog = new ProgressDialog(Main.this){ @Override public boolean onSearchRequested() { return false; } }; On Sunday, 24 June 2012 00:16:40 UTC+8, Mystique wrote: I have a simple ProgressDialog but I realized if I press the search button the dialog will be dismiss. What can I do to disable search button press during this process? dialog = new ProgressDialog(Main.this); dialog.setTitle(Working in progress); dialog.setMessage(Please wait...); dialog.setCancelable(false); dialog.show(); I add a setOnKeyListener but it is still now working. dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH event.getRepeatCount() == 0) { return true; // Pretend we processed it } return false; // Any other keys are still processed as normal } }); -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Disable search button press during ProgressDialog
I did, not working... On Sunday, 24 June 2012 00:37:06 UTC+8, Nobu Games wrote: Try overriding onSearchRequestedhttp://developer.android.com/reference/android/app/Activity.html#onSearchRequested%28%29in your Activity and return false when that dialog is open. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Disable search button press during ProgressDialog
Like this? dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { return keyCode == KeyEvent.KEYCODE_SEARCH; } }); I can seems to get it work either, pressing search button still dismiss the dialog. On Sunday, 24 June 2012 01:03:59 UTC+8, Nobu Games wrote: Okay, I just had a look over at Stackoverflow for that problem and apparently it cannot be fixed that way under all circumstances (for whatever reason, I don't know). You could however restore that dialog in onResume after returning from the search dialog to your activity. I would also try using the debugger and step through the onKey event handler method, have a look at the values that come in. Maybe getRepeatCount() does not return 0. You could also just change your key listener to the following: public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { return keyCode == KeyEvent.KEYCODE_SEARCH; } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Disable search button press during ProgressDialog
This is the answer, stupid me I put it in the wrong dialog.. On Sunday, 24 June 2012 01:17:25 UTC+8, Mystique wrote: Like this? dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { return keyCode == KeyEvent.KEYCODE_SEARCH; } }); I can seems to get it work either, pressing search button still dismiss the dialog. On Sunday, 24 June 2012 01:03:59 UTC+8, Nobu Games wrote: Okay, I just had a look over at Stackoverflow for that problem and apparently it cannot be fixed that way under all circumstances (for whatever reason, I don't know). You could however restore that dialog in onResume after returning from the search dialog to your activity. I would also try using the debugger and step through the onKey event handler method, have a look at the values that come in. Maybe getRepeatCount() does not return 0. You could also just change your key listener to the following: public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { return keyCode == KeyEvent.KEYCODE_SEARCH; } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Am I doing UncaughtExceptionHandler correctly?
Hi, I want to intercept all exceptions with a global exception with a AlerDialog but my UncaughtExceptionHandler doesn't seems to show the dialog. Did I implement it correctly? Many Thanks. I put this in onCreate() - Thread.setDefaultUncaughtExceptionHandler(onDirectoryException); --- The I implemented Thread.UncaughtExceptionHandler - private Thread.UncaughtExceptionHandler onDirectoryException = new Thread.UncaughtExceptionHandler() { String LOG_TAG; @Override public void uncaughtException(Thread thread, Throwable ex) { // TODO Auto-generated method stub Log.e(LOG_TAG, Directory parsing or data connection timeout, ex); new AlertDialog.Builder(getBaseContext()) .setTitle(Information) .setMessage(Data connection timeout. Please try again later.) .setPositiveButton(android.R.string.ok, null) .setCancelable(false) .create() .show(); finish(); } }; -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to retrieve value from onItemClick(AdapterView)?
I have the following, how do I get current position, value C during onItemClick? Many Thanks. adapterS = new SimpleAdapter(this, list, R.layout.sort_by_name, new String[] {A,B, C}, new int[] {R.id.A, R.id.B, R.id.C} ); lv.setAdapter(adapterS); --- lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView? a, View v, int position, long id) { // What do I need to do here to get current position, value C? } }); } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to retrieve value from onItemClick(AdapterView)?
Hi Master Murphy, The list is a ArraryListHashMapString, String ArrayListHashMapString,String list = new ArrayListHashMapString,String(); while (eventType != XmlResourceParser.END_DOCUMENT) { if (eventType == XmlResourceParser.START_TAG) { // Get the name of the tag (eg scores or score) String strName = pullParser.getName(); if (strName.equals(tezt)) { HashMapString,String map = new HashMapString,String(); String A = pullParser.getAttributeValue(null, a); map.put(a,A); String B = pullParser.getAttributeValue(null, b); map.put(b, B); String c = pullParser.getAttributeValue(null, c); map.put(c, C); list.add(map); } } try { eventType = pullParser.next(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to retrieve value from onItemClick(AdapterView)?
Typo during cut/past for: String C = pullParser.getAttributeValue(null, c); On Feb 5, 12:08 am, Mystique joven.ch...@gmail.com wrote: Hi Master Murphy, The list is a ArraryListHashMapString, String ArrayListHashMapString,String list = new ArrayListHashMapString,String(); while (eventType != XmlResourceParser.END_DOCUMENT) { if (eventType == XmlResourceParser.START_TAG) { // Get the name of the tag (eg scores or score) String strName = pullParser.getName(); if (strName.equals(tezt)) { HashMapString,String map = new HashMapString,String(); String A = pullParser.getAttributeValue(null, a); map.put(a,A); String B = pullParser.getAttributeValue(null, b); map.put(b, B); String c = pullParser.getAttributeValue(null, c); map.put(c, C); list.add(map); } } try { eventType = pullParser.next(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to retrieve value from onItemClick(AdapterView)?
Many Thanks to all of you. Both methods work :) -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Listview crash during orientation change
Hi, I have a listview and is working good but i realize if I do a screen orientation change it will crash. Why is that so? Many thanks. --- 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): FATAL EXCEPTION: main 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): java.lang.NullPointerException 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.SimpleAdapter.getCount(SimpleAdapter.java:93) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.AdapterView.checkFocus(AdapterView.java:689) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.AdapterView $AdapterDataSetObserver.onInvalidated(AdapterView.java:813) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.database.DataSetObservable.notifyInvalidated(DataSetObservable.java: 43) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.BaseAdapter.notifyDataSetInvalidated(BaseAdapter.java: 54) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.SimpleAdapter $SimpleFilter.publishResults(SimpleAdapter.java:383) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:282) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.os.Handler.dispatchMessage(Handler.java:99) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.os.Looper.loop(Looper.java:123) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.app.ActivityThread.main(ActivityThread.java:4627) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at java.lang.reflect.Method.invokeNative(Native Method) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at java.lang.reflect.Method.invoke(Method.java:521) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:868) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at dalvik.system.NativeStart.main(Native Method) -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Listview crash during orientation change
Alright, I solved the problem by moving all view element out of OnCreate(); On Feb 5, 9:04 am, Mystique joven.ch...@gmail.com wrote: Hi, I have a listview and is working good but i realize if I do a screen orientation change it will crash. Why is that so? Many thanks. --- 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): FATAL EXCEPTION: main 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): java.lang.NullPointerException 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.SimpleAdapter.getCount(SimpleAdapter.java:93) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.AdapterView.checkFocus(AdapterView.java:689) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.AdapterView $AdapterDataSetObserver.onInvalidated(AdapterView.java:813) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.database.DataSetObservable.notifyInvalidated(DataSetObservable.java : 43) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.BaseAdapter.notifyDataSetInvalidated(BaseAdapter.java: 54) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.SimpleAdapter $SimpleFilter.publishResults(SimpleAdapter.java:383) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:282) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.os.Handler.dispatchMessage(Handler.java:99) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.os.Looper.loop(Looper.java:123) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at android.app.ActivityThread.main(ActivityThread.java:4627) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at java.lang.reflect.Method.invokeNative(Native Method) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at java.lang.reflect.Method.invoke(Method.java:521) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:868) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 02-05 01:04:41.208: ERROR/AndroidRuntime(14593): at dalvik.system.NativeStart.main(Native Method) -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Problem with addTextChangedListener(new TextWatcher()
Hi, What is wrong with my addTextChangedListener() implementation? Something wrong with adapter.getFilter().filter(s)? It crash with this statement, if I remark it then it will not crash but the filter won't work of cause. Many thanks. --- searchbar = (EditText)findViewById(R.id.searchbar); searchbar.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub adapter.getFilter().filter(s); adapter.notifyDataSetChanged(); } }); --- 02-05 03:46:17.212: ERROR/AndroidRuntime(862): FATAL EXCEPTION: main 02-05 03:46:17.212: ERROR/AndroidRuntime(862): java.lang.NullPointerException 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at android.widget.SimpleAdapter.getCount(SimpleAdapter.java:93) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at android.widget.AdapterView.checkFocus(AdapterView.java:689) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at android.widget.AdapterView $AdapterDataSetObserver.onInvalidated(AdapterView.java:813) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at android.database.DataSetObservable.notifyInvalidated(DataSetObservable.java: 43) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at android.widget.BaseAdapter.notifyDataSetInvalidated(BaseAdapter.java: 54) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at android.widget.SimpleAdapter $SimpleFilter.publishResults(SimpleAdapter.java:383) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:282) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at android.os.Handler.dispatchMessage(Handler.java:99) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at android.os.Looper.loop(Looper.java:123) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at android.app.ActivityThread.main(ActivityThread.java:4627) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at java.lang.reflect.Method.invokeNative(Native Method) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at java.lang.reflect.Method.invoke(Method.java:521) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:868) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 02-05 03:46:17.212: ERROR/AndroidRuntime(862): at dalvik.system.NativeStart.main(Native Method) -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to sort HashMap?
Hi DanH, Although I'm a bit lost as Java is a very new language to me, I will try to figure what you mean. SimpleAdapter adapterShop = new SimpleAdapter(this, ppp, R.layout.sort_by_name, new String[] {name,age}, new int[] {R.id.name,R.id.age ); I have this error - The constructor SimpleAdapter(Directory, ArrayListSortable, int, String[], int[]) is undefined Not very sure about it. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to sort HashMap?
Yes sir. On Feb 2, 11:41 pm, TreKing treking...@gmail.com wrote: On Wed, Feb 2, 2011 at 9:12 AM, Mystique joven.ch...@gmail.com wrote: I have this error - The constructor SimpleAdapter(Directory, ArrayListSortable, int, String[], int[]) is undefined Not very sure about it. The best advice I can give you at this point: stop. Just stop. Put your Android project on hold. Put hashmaps and arraylists and generics on hold. Now go get an introductory book on Java and play around with simple Hello World programs where you can familiarize yourself with the language and Eclipse. Knowing how to spot compile time errors and what they mean and knowing how to debug your program is *crucial* to you making any progress. This is a forum for Android SDK questions. You are asking basic Java questions. This thread could go on forever with multiple suggestions on how to solve your given problem but it won't make a lick of sense to you unless you understand the basics. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] What's wrong with this code - SimpleAdapter
Hi, I can't seems to display multiple roll in listview. What is wrong with my code? It just display line 1 - fruit1 and fruit2-4 doesn't appear. --- ArrayListHashMapString,String list = new ArrayListHashMapString,String(); HashMapString,String map = new HashMapString,String(); map.put(fruit1,Apple); map.put(fruit2, Orange); map.put(fruit3, Pear); map.put(fruit4, Banana); list.add(map); SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.fruit_list, new String[] {fruit1,fruit2,fruit3,fruit4}, new int[] {R.id.fruit1,R.id.fruit2, R.id.fruit3, R.id.fruit4} ); ListView lv=(ListView)findViewById(R.id.fruitView); lv.setAdapter(adapter); --- ?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 Spinner android:id=@+id/sort_by android:layout_width=fill_parent android:layout_height=wrap_content android:entries=@array/ default_sorts /Spinner ListView android:id=@+id/fruitView android:layout_width=fill_parent android:layout_height=wrap_content /ListView /LinearLayout --- ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=fill_parent android:layout_height=wrap_content android:background=@drawable/selector android:padding=10sp TextView android:id=@+id/fruit1 android:layout_width=fill_parent android:layout_height=wrap_content android:textAppearance=?android:attr/textAppearanceMediumInverse/ TextView android:id=@+id/fruit2 android:layout_width=fill_parent android:layout_height=wrap_content android:textAppearance=?android:attr/textAppearanceMediumInverse/ TextView android:id=@+id/fruit3 android:layout_width=fill_parent android:layout_height=wrap_content android:textAppearance=?android:attr/textAppearanceMediumInverse/ TextView android:id=@+id/fruit4 android:layout_width=fill_parent android:layout_height=wrap_content android:textAppearance=?android:attr/textAppearanceMediumInverse/ /LinearLayout -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: What's wrong with this code - SimpleAdapter
Ah nice, that fixed all the prob :) On Feb 2, 2:09 am, Kostya Vasilyev kmans...@gmail.com wrote: You are missing android:orientation=vertical on the LinearLayout in layout/fruit_list.xml The default orientation is horizontal, so fruit2..4 are there, but positioned off the right side of the screen. -- Kostya 01.02.2011 20:54, Mystique пишет: Hi, I can't seems to display multiple roll in listview. What is wrong with my code? It just display line 1 - fruit1 and fruit2-4 doesn't appear. --- ArrayListHashMapString,String list = new ArrayListHashMapString,String(); HashMapString,String map = new HashMapString,String(); map.put(fruit1,Apple); map.put(fruit2, Orange); map.put(fruit3, Pear); map.put(fruit4, Banana); list.add(map); SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.fruit_list, new String[] {fruit1,fruit2,fruit3,fruit4}, new int[] {R.id.fruit1,R.id.fruit2, R.id.fruit3, R.id.fruit4} ); ListView lv=(ListView)findViewById(R.id.fruitView); lv.setAdapter(adapter); --- ?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 Spinner android:id=@+id/sort_by android:layout_width=fill_parent android:layout_height=wrap_content android:entries=@array/ default_sorts /Spinner ListView android:id=@+id/fruitView android:layout_width=fill_parent android:layout_height=wrap_content /ListView /LinearLayout --- ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=fill_parent android:layout_height=wrap_content android:background=@drawable/selector android:padding=10sp TextView android:id=@+id/fruit1 android:layout_width=fill_parent android:layout_height=wrap_content android:textAppearance=?android:attr/textAppearanceMediumInverse/ TextView android:id=@+id/fruit2 android:layout_width=fill_parent android:layout_height=wrap_content android:textAppearance=?android:attr/textAppearanceMediumInverse/ TextView android:id=@+id/fruit3 android:layout_width=fill_parent android:layout_height=wrap_content android:textAppearance=?android:attr/textAppearanceMediumInverse/ TextView android:id=@+id/fruit4 android:layout_width=fill_parent android:layout_height=wrap_content android:textAppearance=?android:attr/textAppearanceMediumInverse/ /LinearLayout -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to sort HashMap?
Hi, I know I can use Collections.sort() to sort an ArrayList. But if I have HashMap, how do I do it? Possible to throw it into a temp ArrayList to sort it? ArrayListHashMapString,String mylist = new ArrayListHashMapString,String(); How do I sort this mylist? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to sort HashMap?
Ok, I just read but unclear (java newbie) about this one: ArrayListHashMapString,String list = new ArrayListHashMapString,String(); // I have a loop collecting these value from a XML parser HashMapString,String map = new HashMapString,String(); map.put(name,Tname); map.put(age,Tage); list.add(map); So let say I have test data, I want to sort the age in the ArrayList call list: mary, 12 john, 11 Any sample to look at? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to sort HashMap?
Yes, that is correct. The idea is there, still figuring out how to do it. On Feb 2, 12:12 pm, DanH danhi...@ieee.org wrote: You have a bunch HashMaps of different people, and you want to sort by age? You need to spin through the list of HashMaps and extract age from each one, then insert the age and HashMap into, eg, a TreeMap, with age being the key. On Feb 1, 8:15 pm, Mystique joven.ch...@gmail.com wrote: Ok, I just read but unclear (java newbie) about this one: ArrayListHashMapString,String list = new ArrayListHashMapString,String(); // I have a loop collecting these value from a XML parser HashMapString,String map = new HashMapString,String(); map.put(name,Tname); map.put(age,Tage); list.add(map); So let say I have test data, I want to sort the age in the ArrayList call list: mary, 12 john, 11 Any sample to look at? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to sort HashMap?
Hi Treking, I have many sets of hashmap which each set is a group of related data, I then store it into ArrayList for display into a ListView. Something like that. On Feb 2, 11:11 am, TreKing treking...@gmail.com wrote: On Tue, Feb 1, 2011 at 8:15 PM, Mystique joven.ch...@gmail.com wrote: So let say I have test data, I want to sort the age in the ArrayList call list: mary, 12 john, 11 Your ArrayList is redundant unless you really need a list of maps, which I don't think you do. Any sample to look at? http://developer.android.com/reference/java/util/Comparator.html --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to sort HashMap?
Ok, I did this but runtime error, did I do wrong? --- public class Sortable { private String name; private String age; public Sortable(){ } public Sortable(String name, String age){ this.name = name; this.age = age; } public String getName() { return name; } public String getAge() { return age; } } --- ArrayList test = new ArrayList(); . . . Sortable qqq = new Sortable(name, age); ppp.add(qqq); . . . // Before I try the Collections.sort(), I have error. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to sort HashMap?
sorry shd be: ArrayList qqq = new ArrayList(); What is wrong with my code? On Feb 2, 1:43 pm, Mystique joven.ch...@gmail.com wrote: Ok, I did this but runtime error, did I do wrong? --- public class Sortable { private String name; private String age; public Sortable(){ } public Sortable(String name, String age){ this.name = name; this.age = age; } public String getName() { return name; } public String getAge() { return age; } } --- ArrayList test = new ArrayList(); . . . Sortable qqq = new Sortable(name, age); ppp.add(qqq); . . . // Before I try the Collections.sort(), I have error. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Download file from a password protected http directory
Hi, I'm currently using stream io to download a textbase data file from a site eg example.com/meta/ I want to implement a authentication and tried using a browser to test. It is all good and i need to enter a id/ password before I can access to the protected location. What do I need to add in my android code before I start the stream io? I tried to find some example and mostly pointed me to httpclient method and using http get method. Do I have to modify my old stream io to something else? Many thanks, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Downloading file and asynctask opinion needed
Hi, in my app I have an asynctask to download a file but the file size is only 50kb so it is almost instantaneous. Is worth worth to put it on async? Or I'm asking for trouble and should keep it simple? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Downloading file and asynctask opinion needed
Thank you all. I will keep it that way :) -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Help me on AsyncTask
Hi, I am doing some AsyncTask thing and seems to work ok and after that I open another intent to display a listview. The thing is, if the user press the back key, it return to the caller intent showing the progress dialog and seems to be hanging there until it crash. What did I do wrong? I already do a dialog.dismiss() onPostExecute(). Please help me out. Many thanks, CJ private class LongOperation extends AsyncTaskString, Void, String { ProgressDialog dialog; @Override protected String doInBackground(String... params) { // download something from the net and processing it. // work perfectly return null; } @Override protected void onPostExecute(String result) { // execution of result of Long time consuming operation // some processing from the information taken from the internet (doInBackground) if (dialog.isShowing()) { dialog.dismiss(); } } /* (non-Javadoc) * @see android.os.AsyncTask#onPreExecute() */ @Override protected void onPreExecute() { // Things to be done before execution of long running operation. For example showing ProgessDialog dialog = ProgressDialog.show(Main.this, , Receiving data, true); } @Override protected void onProgressUpdate(Void... values) { // Things to be done while execution of long running operation is in progress. For example updating ProgessDialog } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to do this layout correctly?
Hi, I want to display a textview at the bottom last line of the screen but I have been trying without success. What is the correct way to display it? Many thanks, CJ -- code -- ?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 android:background=@color/desktop android:gravity=center Button android:id=@+id/button1 android:layout_width=wrap_content android:layout_height=wrap_content android:text=@string/button1/ Button android:id=@+id/button2 android:layout_width=wrap_content android:layout_height=wrap_content android:text=@string/button2/ /LinearLayout -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to do this layout correctly?
Yes. I try putting the textview but not success so i showing then plain buttons only. Nice, I will try your suggesting right away :) On Jan 5, 9:31 am, Mark Murphy mmur...@commonsware.com wrote: There is no TextView in your layout. The two main approaches for putting some widget at the bottom last line of the screen are: 1. Use a LinearLayout parent for the widget and the other stuff. Use android:layout_height=0px and android:layout_weight=1 for the other stuff. Use a regular android:layout_height for the widget and no android:layout_weight for it. 2. Use a RelativeLayout parent for the widget and the other stuff. Define the widget as having android:layout_alignParentBottom=true. Define the other stuff as having android:layout_alignParentTop=true and android:layout_above=..., where the ... is the ID of the widget. On Tue, Jan 4, 2011 at 8:22 PM, Mystique joven.ch...@gmail.com wrote: Hi, I want to display a textview at the bottom last line of the screen but I have been trying without success. What is the correct way to display it? Many thanks, CJ -- code -- ?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 android:background=@color/desktop android:gravity=center Button android:id=@+id/button1 android:layout_width=wrap_content android:layout_height=wrap_content android:text=@string/button1/ Button android:id=@+id/button2 android:layout_width=wrap_content android:layout_height=wrap_content android:text=@string/button2/ /LinearLayout -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy Android Training in London:http://bit.ly/smand1andhttp://bit.ly/smand2 -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] String error...pls help to spot
Hi, please help me out. == This is ok == String tmp1 = 123 int seed = Integer.parseInt(tmp1); == This is not ok == ArrayListString tmp2 = new ArrayListString(); String tmp3 = tmp2.get(1); //Added some value to the ArrayList, Toast value of tmp3 and sees the correct value int seed = Integer.parseInt(tmp3); // I get runtime error here, what is wrong? Happy new year. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: String error...pls help to spot
Yes, I want to transfer the value of StringArray tmp2 in position 1 so I do this String tmp3 = tmp2.get(1)... Debugger said: 01-01 13:15:38.378: ERROR/AndroidRuntime(2893): Caused by: java.lang.NumberFormatException: 1.3001505 On Jan 1, 9:09 pm, Kostya Vasilyev kmans...@gmail.com wrote: Use the debugger, Luke :) Check the value of tmp3 just before you call Integer.parseInt. I am assuming you actually added a value to tmp2, so when you call get(1) there is something there. -- Kostya 01.01.2011 15:38, Mystique пишет: Hi, please help me out. == This is ok == String tmp1 = 123 int seed = Integer.parseInt(tmp1); == This is not ok == ArrayListString tmp2 = new ArrayListString(); String tmp3 = tmp2.get(1); //Added some value to the ArrayList, Toast value of tmp3 and sees the correct value int seed = Integer.parseInt(tmp3); // I get runtime error here, what is wrong? Happy new year. -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: String error...pls help to spot
I now do int seed = Integer.parseInt(String.valueOf(tmp3)); and the runtime error seems to go away but I now got error doing the same... long seed2 = Long.parseLong(String.valueOf(tmp4)); What is missing? On Jan 1, 9:21 pm, Mystique joven.ch...@gmail.com wrote: Yes, I want to transfer the value of StringArray tmp2 in position 1 so I do this String tmp3 = tmp2.get(1)... Debugger said: 01-01 13:15:38.378: ERROR/AndroidRuntime(2893): Caused by: java.lang.NumberFormatException: 1.3001505 On Jan 1, 9:09 pm, Kostya Vasilyev kmans...@gmail.com wrote: Use the debugger, Luke :) Check the value of tmp3 just before you call Integer.parseInt. I am assuming you actually added a value to tmp2, so when you call get(1) there is something there. -- Kostya 01.01.2011 15:38, Mystique пишет: Hi, please help me out. == This is ok == String tmp1 = 123 int seed = Integer.parseInt(tmp1); == This is not ok == ArrayListString tmp2 = new ArrayListString(); String tmp3 = tmp2.get(1); //Added some value to the ArrayList, Toast value of tmp3 and sees the correct value int seed = Integer.parseInt(tmp3); // I get runtime error here, what is wrong? Happy new year. -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: String error...pls help to spot
Hi Kostya, The picture is clearer now after your explanation. I have an application server generating Latitude and Longitude in XML and I pullpurse it in my program to compare to current location. So I need to convert the Lat and Lon to Long so I can do a distant to current location calculation. The Integer is a XML value in meter to indicate whether I am in the specific range and is also a string value after the pullpurser. What do I need to do in conversion so I do not have any round/ trancated value? Many thanks, CJ On Jan 1, 9:37 pm, Kostya Vasilyev kmans...@gmail.com wrote: 1.3001505 is not a valid Integer. Either: - fix (round, truncate, etc.) the value to be an Integer when you're putting it into the array; - use Real.parseFloat / Double.parseDouble / NumberFormat to parse a floating-point value; - use a strongly-typed array (ArrayListfloat, ArrayListInteger etc.) instead of an array of strings to avoid conversions altogether. -- Kosyta 01.01.2011 16:21, Mystique пишет: Yes, I want to transfer the value of StringArray tmp2 in position 1 so I do this String tmp3 = tmp2.get(1)... Debugger said: 01-01 13:15:38.378: ERROR/AndroidRuntime(2893): Caused by: java.lang.NumberFormatException: 1.3001505 On Jan 1, 9:09 pm, Kostya Vasilyevkmans...@gmail.com wrote: Use the debugger, Luke :) Check the value of tmp3 just before you call Integer.parseInt. I am assuming you actually added a value to tmp2, so when you call get(1) there is something there. -- Kostya 01.01.2011 15:38, Mystique пишет: Hi, please help me out. == This is ok == String tmp1 = 123 int seed = Integer.parseInt(tmp1); == This is not ok == ArrayListString tmp2 = new ArrayListString(); String tmp3 = tmp2.get(1); //Added some value to the ArrayList, Toast value of tmp3 and sees the correct value int seed = Integer.parseInt(tmp3); // I get runtime error here, what is wrong? Happy new year. -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: String error...pls help to spot
Yes about distant. But I need to compare what the XML spit out which is String format. For example I want to do: m.setLatitude(seedLat); m.setLongitude(seedLon); float distanceInMeters = location.distanceTo(m); SeedLat/SeedLon are pullpurse from a XML source. So I need to convert them prior to the setLatitude/setLongtitude etc. On Jan 1, 9:53 pm, Kostya Vasilyev kmans...@gmail.com wrote: Ah. That's more about computing the distance than a data type problem. See: http://developer.android.com/reference/android/location/Location.html static void distanceBetween(double startLatitude, double startLongitude, double endLatitude, double endLongitude, float[] results) Computes the approximate distance in meters between two locations, and optionally the initial and final bearings of the shortest path between them. or float distanceTo(Location dest) Returns the approximate distance in meters between this location and the given location. -- Kostya 01.01.2011 16:50, Mystique пишет: Hi Kostya, The picture is clearer now after your explanation. I have an application server generating Latitude and Longitude in XML and I pullpurse it in my program to compare to current location. So I need to convert the Lat and Lon to Long so I can do a distant to current location calculation. The Integer is a XML value in meter to indicate whether I am in the specific range and is also a string value after the pullpurser. What do I need to do in conversion so I do not have any round/ trancated value? Many thanks, CJ On Jan 1, 9:37 pm, Kostya Vasilyevkmans...@gmail.com wrote: 1.3001505 is not a valid Integer. Either: - fix (round, truncate, etc.) the value to be an Integer when you're putting it into the array; - use Real.parseFloat / Double.parseDouble / NumberFormat to parse a floating-point value; - use a strongly-typed array (ArrayListfloat, ArrayListInteger etc.) instead of an array of strings to avoid conversions altogether. -- Kosyta 01.01.2011 16:21, Mystique пишет: Yes, I want to transfer the value of StringArray tmp2 in position 1 so I do this String tmp3 = tmp2.get(1)... Debugger said: 01-01 13:15:38.378: ERROR/AndroidRuntime(2893): Caused by: java.lang.NumberFormatException: 1.3001505 On Jan 1, 9:09 pm, Kostya Vasilyevkmans...@gmail.com wrote: Use the debugger, Luke :) Check the value of tmp3 just before you call Integer.parseInt. I am assuming you actually added a value to tmp2, so when you call get(1) there is something there. -- Kostya 01.01.2011 15:38, Mystique пишет: Hi, please help me out. == This is ok == String tmp1 = 123 int seed = Integer.parseInt(tmp1); == This is not ok == ArrayListString tmp2 = new ArrayListString(); String tmp3 = tmp2.get(1); //Added some value to the ArrayList, Toast value of tmp3 and sees the correct value int seed = Integer.parseInt(tmp3); // I get runtime error here, what is wrong? Happy new year. -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to implement this with location.distanceTo()?
Hi, I trying to do this but doesn't seems to get it right. I have runtime error - NumericFormatError, is it because 1.35678 is not Long but Float. Then .setLatitute(Long) is long... how to implement this correctly? // extract value from XML (so it's string value) String Lat = pullParser.getAttributeValue(null, lat); String Lon = pullParser.getAttributeValue(null, lon); // converting this string value to long to call the distanceTo() function long seedLat = Long.parseLong(String.valueOf(Lat)); long seedLon = Long.parseLong(String.valueOf(Lon)); m.setLatitude(seedLat); m.setLongitude(seedLon); float distanceInMeters = location.distanceTo(m); Regards, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to implement this with location.distanceTo()?
Thank you sir, I managed to solve this with: m.setLongitude(Double.valueOf(seedLon)); But is this proper? :D On Jan 2, 12:19 pm, XiaoXiong Weng ad...@littlebearz.com wrote: Wow, smart J From: android-developers@googlegroups.com [mailto:android-develop...@googlegroups.com] On Behalf Of TreKing Sent: Saturday, January 01, 2011 11:12 PM To: android-developers@googlegroups.com Subject: Re: [android-developers] How to implement this with location.distanceTo()? On Sat, Jan 1, 2011 at 9:34 PM, Mystique joven.ch...@gmail.com wrote: I have runtime error - NumericFormatError, is it because 1.35678 is not Long but Float. Yes. Then .setLatitute(Long) is long... how to implement this correctly? Parse the float, scale up by 1E6, then cast to long. --- - - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to do this kind of screen alignment?
Hi, I know fixing the point in the app to draw image/text are bad practices and I'm trying to do this correctly but been far from successful. Any code example to do this layout for both portrait and landscape orientation? | | | | | | | | |(graphics a) (graphics b) | | Text a Text b | | | |(graphics c) (graphics d) | | Text c Text d | | | | | | | | | | | --- I'm trying to achieve layout similar to Google's places app. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to do this kind of screen alignment?
Happy New Year TreKing :) Right, I did try using table but the column will be stretch if the text is longer than the image. Is it suppose to work this way? or it is possible to wrap the longer text to 2nd line? I am now thinking whether there are ways to dynamically take the screen measurement and draw during run time. @@ On Jan 1, 12:13 am, TreKing treking...@gmail.com wrote: On Fri, Dec 31, 2010 at 2:52 AM, Mystique joven.ch...@gmail.com wrote: Any code example to do this layout for both portrait and landscape orientation? The likelihood of finding code examples that perfectly solve the particular layout problem you are having at any given time is pretty much zero. However, this is a pretty simple layout. Looks a like a two-row, two-column table, with each cell containing a centered vertical linear layout with an image and text. Then play with the padding and margins until it meets your needs. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Listview using ArrayAdapter trouble
Wow, this is new knowledge to me. Thanks! On Dec 31, 5:51 am, jotobjects jotobje...@gmail.com wrote: On Dec 29, 11:00 pm, Mystique joven.ch...@gmail.com wrote: Good day, I do not understand the outer LinearLayout you was pointing out. Don't we need to declare a Layout so we can put component such as listview, textview etc? No - this is an unnecessary layer that is quite expensive in memory and CPU resources. You have an Activity that probably has a call to setContentView(v). Here 'v' can be any View. It does not have to be a layout. In general, View widgets do not need to be declared inside layout widgets (layouts are ViewGroup instances). For example ---list.xml--- ?xml version=1.0 encoding=utf-8? TextView xmlns:android=http://schemas.android.com/apk/res/android; ... / On Dec 30, 2:51 pm, jotobjects jotobje...@gmail.com wrote: Does android.widget.TwoLineListItem do what you want? BTW - looks like the outer LinearLayout is unnecessary in list.xml and listadapter.xml. On Dec 29, 5:41 pm, Mystique joven.ch...@gmail.com wrote: Hi, I have an app that I mine data with an ArrayList and load to an ArrayAdapter to display as listview. How can I do more than 1 textview item in 1 roll? My code is: ---list.xml--- ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=fill_parent android:layout_height=fill_parent android:background=@drawable/selector android:padding=10sp TextView android:id=@+id/listA android:layout_width=wrap_content android:layout_height=wrap_content android:singleLine=true android:gravity=center_vertical|left android:textAppearance=?android:attr/ textAppearanceMediumInverse /TextView /LinearLayout --listadapter.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 ListView android:id=@+id/listView android:cacheColorHint=#00 android:layout_width=fill_parent android:layout_height=wrap_content / /LinearLayout --code--- lv1=(ListView)findViewById(R.id.listView); lv1.setAdapter(new ArrayAdapterString(this, R.layout.listadapter, R.id.listA, allTheList2)); all is ok for single line. --- try to do but fail --- Create another TextView such as: TextView android:id=@+id/listB blah blah... then add another: lv1.setAdapter(new ArrayAdapterString(this, R.layout.listadapter, R.id.listB, allTheList2)); But fail. Basically, what I want to do is to mine data DATA_FIELD1, DATA_FIELD2 populate into a listview to display (single roll): DATA_FIELD1 (Larger font) DATA_FIELD2 (Smaller font) I can't find any example to do this, can anyone please advice? Many Thanks, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Listview using ArrayAdapter trouble
Hi, I have an app that I mine data with an ArrayList and load to an ArrayAdapter to display as listview. How can I do more than 1 textview item in 1 roll? My code is: ---list.xml--- ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=fill_parent android:layout_height=fill_parent android:background=@drawable/selector android:padding=10sp TextView android:id=@+id/listA android:layout_width=wrap_content android:layout_height=wrap_content android:singleLine=true android:gravity=center_vertical|left android:textAppearance=?android:attr/ textAppearanceMediumInverse /TextView /LinearLayout --listadapter.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 ListView android:id=@+id/listView android:cacheColorHint=#00 android:layout_width=fill_parent android:layout_height=wrap_content / /LinearLayout --code--- lv1=(ListView)findViewById(R.id.listView); lv1.setAdapter(new ArrayAdapterString(this, R.layout.listadapter, R.id.listA, allTheList2)); all is ok for single line. --- try to do but fail --- Create another TextView such as: TextView android:id=@+id/listB blah blah... then add another: lv1.setAdapter(new ArrayAdapterString(this, R.layout.listadapter, R.id.listB, allTheList2)); But fail. Basically, what I want to do is to mine data DATA_FIELD1, DATA_FIELD2 populate into a listview to display (single roll): DATA_FIELD1 (Larger font) DATA_FIELD2 (Smaller font) I can't find any example to do this, can anyone please advice? Many Thanks, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Listview using ArrayAdapter trouble
Good day, I do not understand the outer LinearLayout you was pointing out. Don't we need to declare a Layout so we can put component such as listview, textview etc? On Dec 30, 2:51 pm, jotobjects jotobje...@gmail.com wrote: Does android.widget.TwoLineListItem do what you want? BTW - looks like the outer LinearLayout is unnecessary in list.xml and listadapter.xml. On Dec 29, 5:41 pm, Mystique joven.ch...@gmail.com wrote: Hi, I have an app that I mine data with an ArrayList and load to an ArrayAdapter to display as listview. How can I do more than 1 textview item in 1 roll? My code is: ---list.xml--- ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=fill_parent android:layout_height=fill_parent android:background=@drawable/selector android:padding=10sp TextView android:id=@+id/listA android:layout_width=wrap_content android:layout_height=wrap_content android:singleLine=true android:gravity=center_vertical|left android:textAppearance=?android:attr/ textAppearanceMediumInverse /TextView /LinearLayout --listadapter.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 ListView android:id=@+id/listView android:cacheColorHint=#00 android:layout_width=fill_parent android:layout_height=wrap_content / /LinearLayout --code--- lv1=(ListView)findViewById(R.id.listView); lv1.setAdapter(new ArrayAdapterString(this, R.layout.listadapter, R.id.listA, allTheList2)); all is ok for single line. --- try to do but fail --- Create another TextView such as: TextView android:id=@+id/listB blah blah... then add another: lv1.setAdapter(new ArrayAdapterString(this, R.layout.listadapter, R.id.listB, allTheList2)); But fail. Basically, what I want to do is to mine data DATA_FIELD1, DATA_FIELD2 populate into a listview to display (single roll): DATA_FIELD1 (Larger font) DATA_FIELD2 (Smaller font) I can't find any example to do this, can anyone please advice? Many Thanks, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Listview selector no more color
Thanks Sandeep, It works nicely. Just curious, is this the usual way to do it? Regards, CJ On Dec 28, 7:58 pm, Sandeep N M donks...@gmail.com wrote: Add this to layout/list.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=wrap_content android:background=#f8f8f8 ListView android:id=@+id/list android:layout_width=fill_parent android:layout_height=wrap_content android:layout_weight=1 android:cacheColorHint=#00 / /LinearLayout Add this in drawable/selector.xml ?xml version=1.0 encoding=utf-8? selector xmlns:android=http://schemas.android.com/apk/res/android; item android:state_pressed=true android:drawable=@drawable/ orange / item android:drawable=@drawable/white / /selector orange and white are 1X1 pixel images of what ever color you want. add this to layout/item.xml LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:id=@+id/vw1 android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=horizontal android:background=@drawable/selector TextView android:id=@+id/text android:textColor=#151515 android:textSize=16sp android:layout_width=220px android:layout_height=60px android:layout_marginLeft=8px android:typeface=sans / /LinearLayout Regards, Sandeep On Dec 28, 9:02 am, Mystique joven.ch...@gmail.com wrote: I just want the selector to be as default, when I select an item I see color change. But when I change my xml the selector is no longer working. Why is this so? --- ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=fill_parent android:layout_height=fill_parent android:background=@color/background android:padding=10sp TextView android:id=@+id/list android:layout_width=fill_parent android:layout_height=fill_parent android:singleLine=true android:textAppearance=?android:attr/textColor android:gravity=center_vertical|left /TextView /LinearLayout --- Many thanks, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Is this normal textview or webview?
Hi Master TreKing, I know it is a listview but is it a textview in the listview or webview in a listview? I wanted to do something like this but I can't seems to get it right modifying the textview so is wondering is it something special to create this look or it is just same text component in normal listview :) Regards, CJ On Dec 27, 1:56 pm, TreKing treking...@gmail.com wrote: On Sun, Dec 26, 2010 at 8:41 PM, Mystique joven.ch...@gmail.com wrote: Hi, how to achieve this listview? Use the same layout and style as the picture. Is it textview or webview? Probably a listview. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Is this normal textview or webview?
Thanks, my 2 great teachers. I will check them out. On Dec 27, 11:05 pm, Mark Murphy mmur...@commonsware.com wrote: On Mon, Dec 27, 2010 at 9:50 AM, Mystique joven.ch...@gmail.com wrote: I know it is a listview but is it a textview in the listview or webview in a listview? Most likely, each row is three TextViews in a RelativeLayout, where the top TextView really should have an android:ellipsize entry but doesn't. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Listview selector no more color
I just want the selector to be as default, when I select an item I see color change. But when I change my xml the selector is no longer working. Why is this so? --- ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=fill_parent android:layout_height=fill_parent android:background=@color/background android:padding=10sp TextView android:id=@+id/list android:layout_width=fill_parent android:layout_height=fill_parent android:singleLine=true android:textAppearance=?android:attr/textColor android:gravity=center_vertical|left /TextView /LinearLayout --- Many thanks, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Is this normal textview or webview?
Hi, how to achieve this listview? Is it textview or webview? http://172.31.254.241/www.android.com/market/data/screenshots/com.zenmobi.android.app.nfl.jetsnews0.png Regards, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] xml data best practise
Hi, I'm working on a app that parse xml data from web. Is it better to download the entire xml file to a temp director and parse it or it is better to parse as stream to the memory? What is the common practice? Regards, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Parse file located in sdcard
Hi, Currently I am testing parsing file from /res: XmlResourceParser test = getResources().getXml(R.xml.test); If I want to parse from let say /sdcard/test/test.xml What statement do I use? Many Thanks, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to mkdirs() with /sdcard/.testdir
Hi, I can mkdirs() with name like /sdcard/testdir but why not with a . such as /sdcard/.testdir? Do I need to do something to the string name? Regards, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] loading xml items to an array not working... what is wrong with my code?
Hi, I have a xml file call groups.xml. I want to read the value name and store in array lv_arrr and load it into an adapter: lv1.setAdapter(new ArrayAdapterString(this, R.layout.group_list, R.id.grouplist, lv_arrr)); The program crash during runtime. What did I do wrong in the code can anyone help to take a look? Many thanks. ---/res/xml/groups.xml--- ?xml version=1.0 encoding=utf-8? !-- This is a mock score XML chunk -- groups group name=Apple / group name=Orange / group name=Pineapple / /groups --- public class Manual extends Activity { private ListView lv1; private String lv_arrr[]; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.manual); XmlResourceParser allGroups = getResources().getXml(R.xml.groups); try { processGroups(allGroups); } catch (Exception e) { //Log.e(DEBUG_TAG, Failed to load malls, e); } lv1=(ListView)findViewById(R.id.myListView); lv1.setAdapter(new ArrayAdapterString(this, R.layout.group_list, R.id.grouplist, lv_arrr)); lv1.setTextFilterEnabled(true); lv1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView? a, View v, int position, long id) { AlertDialog.Builder adb=new AlertDialog.Builder(Manual.this); adb.setTitle(LVSelectedItemExample); adb.setMessage(Selected Item is = +lv1.getItemAtPosition(position)); adb.setPositiveButton(Ok, null); adb.show(); } }); } private void processGroups(XmlResourceParser groups) throws XmlPullParserException, IOException { int eventType = -1; // Find Score records from XML while (eventType != XmlResourceParser.END_DOCUMENT) { if (eventType == XmlResourceParser.START_TAG) { // Get the name of the tag (eg scores or score) String strName = groups.getName(); if (strName.equals(group)) { String Name = groups.getAttributeValue(null, name); lv_arrr[eventType] = Name; } } eventType = groups.next(); } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: loading xml items to an array not working... what is wrong with my code?
I think it is something to do with this. --- if (strName.equals(group)) { String Name = groups.getAttributeValue(null, name); lv_arrr[eventType] = Name; --- When I check, Name did contain the correct value. I remember array starts with [0] so I create another counter call i with i++ to replace lv_arrr[i] = Name; Somehow lv_arrr still contain null. Why is that so? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Basic String Array question :(
Sorry, if this is too basic and not entirely Android.. but android is part java too, so I don't have to hop forum. I believe someone else might encounter this too. I'm putting some statement in the Android basically reading an xml file and cast the value into an array to be use as listview but I encounter some problem. To keep thing simple and readable, I simplify it as below: String[] lv_arr; for(int i=1; i11; i++){ lv_arr[i] = hello; } When I toast the value of lv_arr[i] it is null. If I do this: String[] lv_arr = {hello, hello, hello} + the for loop, I can get the hello value when I do the toast. but [3]-[10] is still null value. Why is that so? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Basic String Array question :(
Dear King, array indexing is zero-based, so you would start your loop from 0 and go to 9 (where i 10) Right sir, I'm aware it's for illustration and I forgot to change it. You've initialized an array to exactly three elements. Anything after that This part is essential, if I do not know how many element I have then I cannot declare it predefine but declare array without value to be filled later. That is why I have a for loop to extract value from a XML field to fill into the array. But the array seems to be null unless I have pre- initialise it with something. The for loop only fill the data for dummy value I put, if I initialise 3 dummy values the for loop fill exactly 3 values and leave the rest empty. If i set set 5 dummy values, the 5 get filled correctly. Java is not my native and I have read a few java books and written full running android apps. Then, still unable to figure this out... maybe I need some beer :D On Dec 25, 11:08 am, TreKing treking...@gmail.com wrote: On Fri, Dec 24, 2010 at 8:12 PM, Mystique joven.ch...@gmail.com wrote: String[] lv_arr; for(int i=1; i11; i++){ lv_arr[i] = hello; } When I toast the value of lv_arr[i] it is null. If this is your actual code, you need to initialize the array. String[] lv_arr = new String[11]; Second, array indexing is zero-based, so you would start your loop from 0 and go to 9 (where i 10). If I do this: String[] lv_arr = {hello, hello, hello} + the for loop, I can get the hello value when I do the toast. but [3]-[10] is still null value. You've initialized an array to exactly three elements. Anything after that (index 3 and above) is non-existent. These are really basic Java concepts. If you don't understand this, I highly recommend you go study Java on it's own and figure this stuff out before trying to do an Android project. You're going to run into a lot of headaches if you try to learn both at the same time. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Basic String Array question :(
Tried ArrayList and it works! On Dec 25, 11:45 am, TreKing treking...@gmail.com wrote: On Fri, Dec 24, 2010 at 9:32 PM, Mystique joven.ch...@gmail.com wrote: This part is essential, if I do not know how many element I have then I cannot declare it predefine but declare array without value to be filled later. Then don't use an array - try ArrayList. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] The import org.apache.http.entity.mime cannot be resolved
Hi, I'm trying out sample example from a book to understand how the code works but I have this error: The import org.apache.http.entity.mime cannot be resolved What is that I need to do? 10Q. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Is it possible to create SQlite with pre-entered data?
Hi, I want to create a SQlite db with pre-entered data so I can load them into a listview. How can this be done? Many thanks, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Is it possible to create SQlite with pre-entered data?
Beautiful, thanks. :) On Dec 21, 12:29 am, Kostya Vasilyev kmans...@gmail.com wrote: I guess by pre-entered you mean that you created a SQLite database populated with data somewhere else (like your development system). You can add the database file to your application (res/raw or res/assets), then at runtime, first time the application is run, copy that file into your application's data directory (call Context.getDatabasePath to gets target file location). After that, your application can open the database as usual. Make sure you don't use any features of SQLite that are more recent than the version in Android. -- Kostya 20.12.2010 19:09, Mystique пишет: Hi, I want to create a SQlite db with pre-entered data so I can load them into a listview. How can this be done? Many thanks, CJ -- Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Want to write a forum reader
Thanks TreKing, You are right, been doing my research in google now. Thanks for pointing out the light. On Dec 9, 7:27 am, TreKing treking...@gmail.com wrote: On Tue, Dec 7, 2010 at 3:11 AM, Mystique joven.ch...@gmail.com wrote: Can anyone give me some light what is involve and generally how to do it? This is ridiculously broad and you're probably not going to get a good answer in this group. 1. What is it involve to do web sign in? http? any example/code documentation to study? This has nothing to do with Android specifically and you're probably better off trying other groups / forums related to setting up and running a forum. 2. Formating of forum message to the mobile edition? That's not a question ... General ideal which direction to find so I can do the research. I would spend several hours using google.com, for starters. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Want to write a forum reader
Hi, I've done some Android programming and 2 apps on the market. I'm now thinking to write a simplified mobile reader for a forum. Can anyone give me some light what is involve and generally how to do it? 1. What is it involve to do web sign in? http? any example/code documentation to study? 2. Formating of forum message to the mobile edition? General ideal which direction to find so I can do the research. Rgds, CJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to fix: method getSharedPreferences(String, int) is undefined?
Hi, I have the following code but there is an error: The method getSharedPreferences(String, int) is undefined for the type EventsData. Does it mean I need to extend both SQLLiteOpenHelper and Activity? How to do that or how to fix this? Many thanks. ---code--- import android.content.Context; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; public class EventsData extends SQLiteOpenHelper { // code blah, bah private boolean ABC() { String PREFS = abc; final SharedPreferences settings = this.getSharedPreferences(PREFS, 0); // code blah blah } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Possible to disable a permission in the program code?
Hi, my app uses Internet permission, is there a way to disable it in the code? Many thanks. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Can ScrollView and Scrollbars in EditText co-exist?
Hi, I have a Dialog implemented with scrollview and a multiline edittext item in the scrollview. I see that I can use the scrollbar in the edittext as the scrollview will take over it. Can they co-exist and work together? Many thanks. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Wrap text for EditText - automatically go to new line?
Hi,can I limit the edittext field so it wrap text around the input box instead of scrolling right unless I hit return? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Wrap text for EditText - automatically go to new line?
Ok, I found it. android:scrollHorizontally=false On Sep 20, 2:07 am, Mystique joven.ch...@gmail.com wrote: Hi,can I limit the edittext field so it wrap text around the input box instead of scrolling right unless I hit return? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Can ScrollView and Scrollbars in EditText co-exist?
Hi Treking, Yes, sounds logical. I have a dialog that has many items and will display beyond the bottom of the screen and also in it there's a EditText element that can be large. Any suggestion you have? Many thanks. On Sep 20, 3:17 am, TreKing treking...@gmail.com wrote: On Sun, Sep 19, 2010 at 12:56 PM, Mystique joven.ch...@gmail.com wrote: Can they co-exist and work together? In general, I believe, you cannot (or should not) put auto-scrolling components inside a ScrollView. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Can ScrollView and Scrollbars in EditText co-exist?
Sounds like a plan but how to do that? Do you mean when I click on the EditText field it open up to a larger window? On Sep 20, 10:08 am, Dianne Hackborn hack...@android.com wrote: Or just let it grow to always show all of its content in the larger scroll view, as it done in many places in the standard UI (contacts, gmail, etc). -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to do this correctly in SQLite?
Hi, sorry about the variable names aren't consistent. I change it when I paste here to make it readable, my mistake for the confusion. About the single code, I want the value of temp instead of the string temp ('temp') therefore I have not single code. Many thanks. On Sep 16, 2:28 pm, String sterling.ud...@googlemail.com wrote: You're missing the inner (single) quotes around the temp string. Also, your variable names aren't consistent, but I'm assuming that's just in your post here - the compiler would have caught that for you. In any case, your code should be: String temp = temp; db.execSQL(INSERT INTO + TABLE_NAME + VALUES (0 'A', 'Hello', '', ' + temp + ', '');); On Sep 16, 6:37 am, Mystique joven.ch...@gmail.com wrote: Hi, I want to insert a String value call temp but I don't seems to get it working for the INSERT INTO statement. Anything wrong with the code? This is the initialization to create table and insert some default values into the table if the database doesn't exist. Many Thanks. ---code--- @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE TABLE + TABLE_NAME + ( + _ID + INTEGER PRIMARY KEY AUTOINCREMENT, + FIELD1 + VARCHAR(1), + FIELD2 + TEXT, + FIELD3 + TEXT, + FIELD4 + TEXT, + FIELD5 + TEXT);); String tmp = temp; db.execSQL(INSERT INTO + TABLE_NAME + VALUES (0 'A', 'Hello', '', + temp + , '');); } ---code--- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to do this correctly in SQLite?
Hi String, Thanks for your help. It is working now, learn something new today. Cheers. On Sep 16, 3:04 pm, Mystique joven.ch...@gmail.com wrote: Hi, sorry about the variable names aren't consistent. I change it when I paste here to make it readable, my mistake for the confusion. About the single code, I want the value of temp instead of the string temp ('temp') therefore I have not single code. Many thanks. On Sep 16, 2:28 pm, String sterling.ud...@googlemail.com wrote: You're missing the inner (single) quotes around the temp string. Also, your variable names aren't consistent, but I'm assuming that's just in your post here - the compiler would have caught that for you. In any case, your code should be: String temp = temp; db.execSQL(INSERT INTO + TABLE_NAME + VALUES (0 'A', 'Hello', '', ' + temp + ', '');); On Sep 16, 6:37 am, Mystique joven.ch...@gmail.com wrote: Hi, I want to insert a String value call temp but I don't seems to get it working for the INSERT INTO statement. Anything wrong with the code? This is the initialization to create table and insert some default values into the table if the database doesn't exist. Many Thanks. ---code--- @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE TABLE + TABLE_NAME + ( + _ID + INTEGER PRIMARY KEY AUTOINCREMENT, + FIELD1 + VARCHAR(1), + FIELD2 + TEXT, + FIELD3 + TEXT, + FIELD4 + TEXT, + FIELD5 + TEXT);); String tmp = temp; db.execSQL(INSERT INTO + TABLE_NAME + VALUES (0 'A', 'Hello', '', + temp + , '');); } ---code--- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] onResume is always called on TabActivity so onCreate is not necessary?
Is it suppose to work this way? I have a TabActivity with 3 tabs, each tab started an activity and I realise when a tab is clicked onResume is call. If I have onCreate, when app start it will launch onCreate and then onResume immediately. So, I can just get ride of onCreate in this case? Thanks. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Loading raw resource text file hang...
Hi, I use this method couples of occasion to load text file to display as help file. But I don't know why the following code didn't work. It seems to hang and logcat says OutOfMemoryError? All I did was break this out as an separate activity... Can anyone help me to catch the problem? ---xml--- ?xml version=1.0 encoding=utf-8? ScrollView xmlns:android=http://schemas.android.com/apk/res/android; android:id=@+id/helptab android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent TextView android:id=@+id/helptext android:layout_width=fill_parent android:layout_height=wrap_content / /ScrollView ---code--- import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class Help extends Activity { /** Called when the activity is first created. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.help); InputStream iFile = getResources().openRawResource(R.raw.help); try { TextView helpText = (TextView) findViewById(R.id.helptext); String strFile = inputStreamToString(iFile); helpText.setText(strFile); } catch (Exception e) { } } public String inputStreamToString(InputStream is) throws IOException { StringBuffer sBuffer = new StringBuffer(); DataInputStream dataIO = new DataInputStream(is); String strLine = ; while ((strLine = dataIO.readLine()) != ) { sBuffer.append(strLine + \n); } dataIO.close(); is.close(); return sBuffer.toString(); } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Loading raw resource text file hang...
I'm not sure... I've been using this in my previous app. I change to this code instead and it is working. ---code--- TextView helpTxt = (TextView)findViewById(R.id.helptext); helpTxt.setText(readTxt()); } private String readTxt() { InputStream inputStream = getResources().openRawResource(R.raw.help); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); int i; try { i = inputStream.read(); while (i != -1) { byteArrayOutputStream.write(i); i = inputStream.read(); } inputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return byteArrayOutputStream.toString(); } } On Sep 16, 3:12 am, TreKing treking...@gmail.com wrote: On Wed, Sep 15, 2010 at 1:53 PM, Mystique joven.ch...@gmail.com wrote: while ((strLine = dataIO.readLine()) != ) { sBuffer.append(strLine + \n); This seems suspect. Shouldn't you be checking for null? --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Loading raw resource text file hang...
Right, it was suppose to be: while ((strLine = dataIO.readLine()) != null) { sBuffer.append(strLine + \n); I don't know why it was change. Thanks you guys. On Sep 16, 3:18 am, DanH danhi...@ieee.org wrote: And, of course, DataInputStream.readLine is deprecated. On Sep 15, 1:53 pm, Mystique joven.ch...@gmail.com wrote: Hi, I use this method couples of occasion to load text file to display as help file. But I don't know why the following code didn't work. It seems to hang and logcat says OutOfMemoryError? All I did was break this out as an separate activity... Can anyone help me to catch the problem? ---xml--- ?xml version=1.0 encoding=utf-8? ScrollView xmlns:android=http://schemas.android.com/apk/res/android; android:id=@+id/helptab android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent TextView android:id=@+id/helptext android:layout_width=fill_parent android:layout_height=wrap_content / /ScrollView ---code--- import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class Help extends Activity { /** Called when the activity is first created. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.help); InputStream iFile = getResources().openRawResource(R.raw.help); try { TextView helpText = (TextView) findViewById(R.id.helptext); String strFile = inputStreamToString(iFile); helpText.setText(strFile); } catch (Exception e) { } } public String inputStreamToString(InputStream is) throws IOException { StringBuffer sBuffer = new StringBuffer(); DataInputStream dataIO = new DataInputStream(is); String strLine = ; while ((strLine = dataIO.readLine()) != ) { sBuffer.append(strLine + \n); } dataIO.close(); is.close(); return sBuffer.toString(); } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to do this correctly in SQLite?
Hi, I want to insert a String value call temp but I don't seems to get it working for the INSERT INTO statement. Anything wrong with the code? This is the initialization to create table and insert some default values into the table if the database doesn't exist. Many Thanks. ---code--- @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE TABLE + TABLE_NAME + ( + _ID + INTEGER PRIMARY KEY AUTOINCREMENT, + FIELD1 + VARCHAR(1), + FIELD2 + TEXT, + FIELD3 + TEXT, + FIELD4 + TEXT, + FIELD5 + TEXT);); String tmp = temp; db.execSQL(INSERT INTO + TABLE_NAME + VALUES (0 'A', 'Hello', '', + temp + , '');); } ---code--- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] What is the maximum length for text datatype in SQLite?
I can't seems to find this information, anyone know? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Possible to display a string or button on top a listview?
Hi, I can seems to get it write. What is wrong with my layout? ---code--- ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:id=@+id/main android:layout_width=fill_parent android:layout_height=fill_parent TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/test / !-- Note built-in ids for 'list' and 'empty' -- ListView android:id=@android:id/list android:layout_width=wrap_content android:layout_height=wrap_content/ TextView android:id=@android:id/empty android:layout_width=wrap_content android:layout_height=wrap_content android:text=@string/empty / /LinearLayout -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Possible to display a string or button on top a listview?
Hi, thanks for the advice. Not sure what is wrong, I try putting android:layout_height=0px and android:layout_weight=1 but it still doesn't appear. On Sep 12, 2:55 pm, Dianne Hackborn hack...@android.com wrote: You can't use wrap_content with a list view, because that will cause it to expand to whatever size its full contents are. If you want the list view to expand to fill all space except the text views above and below, use android:layout_height=0px and android:layout_weight=1 on it. On Sat, Sep 11, 2010 at 11:42 PM, Mystique joven.ch...@gmail.com wrote: Hi, I can seems to get it write. What is wrong with my layout? ---code--- ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:id=@+id/main android:layout_width=fill_parent android:layout_height=fill_parent TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/test / !-- Note built-in ids for 'list' and 'empty' -- ListView android:id=@android:id/list android:layout_width=wrap_content android:layout_height=wrap_content/ TextView android:id=@android:id/empty android:layout_width=wrap_content android:layout_height=wrap_content android:text=@string/empty / /LinearLayout -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to get value from ListView onListItemClick?
Another question seeking help. When I click the listview item, I pop up a form as dialog format to enable user to edittext. All is fine, I have an option to cancel editing by calling removeDialog(ID1); But if the user click back (android key) instead of the cancel button and pick another item in the listview, the edittext will contain the old data. I think because back did not release the dialog and it recall the same thing again instead of re-inflating one with the newly selected data? How to solve this issue? On Sep 11, 11:19 pm, Pang joyb...@163.com wrote: c.getString(c.getColumnIndexOrThrow(UN)) On 9月11日, 下午8时37分, Mystique joven.ch...@gmail.com wrote: Cancel my last qns, I understood and get it work already :) On Sep 11, 8:32 pm, Mystique joven.ch...@gmail.com wrote: Dear Mr. Murphy, Thanks, I understood this part ok c.moveToPosition(position); // where c is your Cursor String temp=c.getString(...); // where ... is whatever column number My cursor was created in onCreate, how do I initial it in public void onListItemClick? This part I do not understand. On Sep 11, 8:19 pm, Mark Murphy mmur...@commonsware.com wrote: On Sat, Sep 11, 2010 at 8:04 AM, Mystique joven.ch...@gmail.com wrote: So if I want to get value of UN, I do this - String temp = moveToPosition(UN)? No. c.moveToPosition(position); // where c is your Cursor String temp=c.getString(...); // where ... is whatever column number you are seeking -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to get value from ListView onListItemClick?
Also, my listview doesn't seems to update/refresh with new data until I refresh it manually. How do I refresh the new listview after updating? On Sep 13, 1:28 am, Mystique joven.ch...@gmail.com wrote: Another question seeking help. When I click the listview item, I pop up a form as dialog format to enable user to edittext. All is fine, I have an option to cancel editing by calling removeDialog(ID1); But if the user click back (android key) instead of the cancel button and pick another item in the listview, the edittext will contain the old data. I think because back did not release the dialog and it recall the same thing again instead of re-inflating one with the newly selected data? How to solve this issue? On Sep 11, 11:19 pm, Pang joyb...@163.com wrote: c.getString(c.getColumnIndexOrThrow(UN)) On 9月11日, 下午8时37分, Mystique joven.ch...@gmail.com wrote: Cancel my last qns, I understood and get it work already :) On Sep 11, 8:32 pm, Mystique joven.ch...@gmail.com wrote: Dear Mr. Murphy, Thanks, I understood this part ok c.moveToPosition(position); // where c is your Cursor String temp=c.getString(...); // where ... is whatever column number My cursor was created in onCreate, how do I initial it in public void onListItemClick? This part I do not understand. On Sep 11, 8:19 pm, Mark Murphy mmur...@commonsware.com wrote: On Sat, Sep 11, 2010 at 8:04 AM, Mystique joven.ch...@gmail.com wrote: So if I want to get value of UN, I do this - String temp = moveToPosition(UN)? No. c.moveToPosition(position); // where c is your Cursor String temp=c.getString(...); // where ... is whatever column number you are seeking -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to get value from ListView onListItemClick?
Hi TrekKing, I implemented the onCancelListener and have it working good, thanks. Now need to figure out how to refresh the listview... On Sep 13, 3:36 am, TreKing treking...@gmail.com wrote: 2010/9/12 Mystique joven.ch...@gmail.com How to solve this issue? 1 - Add an onCancelListener to your dialog that calls removeDialog(ID1) on it so it gets removed regardless of how it's canceled. or 2 - Override onPrepareDialog to set the data in the dialog as necessary based on the item clicked. This is a little more cumbersome. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to get value from ListView onListItemClick?
I've solved the refresh listview too :) nice. On Sep 13, 11:42 am, Mystique joven.ch...@gmail.com wrote: Hi TrekKing, I implemented the onCancelListener and have it working good, thanks. Now need to figure out how to refresh the listview... On Sep 13, 3:36 am, TreKing treking...@gmail.com wrote: 2010/9/12 Mystique joven.ch...@gmail.com How to solve this issue? 1 - Add an onCancelListener to your dialog that calls removeDialog(ID1) on it so it gets removed regardless of how it's canceled. or 2 - Override onPrepareDialog to set the data in the dialog as necessary based on the item clicked. This is a little more cumbersome. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How to get value from ListView onListItemClick?
Hi, i can add to a db and list as a listview. When I click a list item using onListItemClick, what statement do I need to get the value? Thanks in advance. ---code--- public class Main extends ListActivity { private static String[] FROM = { _ID, DESCRIPTION, UN }; private static String ORDER_BY = DESCRIPTION + ASC; private static int[] TO = {R.id.itemrowid, R.id.itemdescription, R.id.itemun }; private EventsData events; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); events = new EventsData(this); try { Cursor cursor = getEvents(); showEvents(cursor); } finally { events.close(); } public void onListItemClick(ListView parent, View v, int position, long id) { // What statement to put here to get the value of _ID, DESCRIPTION, UN // selected? } private Cursor getEvents() { // Perform a managed query. The Activity will handle closing // and re-querying the cursor when needed. SQLiteDatabase db = events.getReadableDatabase(); Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null, null, ORDER_BY); startManagingCursor(cursor); return cursor; } private void showEvents(Cursor cursor) { // Set up data binding SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.item, cursor, FROM, TO); setListAdapter(adapter); } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to get value from ListView onListItemClick?
So if I want to get value of UN, I do this - String temp = moveToPosition(UN)? On Sep 11, 7:55 pm, Mark Murphy mmur...@commonsware.com wrote: On Sat, Sep 11, 2010 at 7:54 AM, Mystique joven.ch...@gmail.com wrote: Hi, i can add to a db and list as a listview. When I click a list item using onListItemClick, what statement do I need to get the value? :: snip :: public void onListItemClick(ListView parent, View v, int position, long id) { // What statement to put here to get the value of _ID, DESCRIPTION, UN // selected? } The fourth parameter (id) is _ID. The third parameter (position) can be used with moveToPosition() on your Cursor to access anything else you may need. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to get value from ListView onListItemClick?
Dear Mr. Murphy, Thanks, I understood this part ok c.moveToPosition(position); // where c is your Cursor String temp=c.getString(...); // where ... is whatever column number My cursor was created in onCreate, how do I initial it in public void onListItemClick? This part I do not understand. On Sep 11, 8:19 pm, Mark Murphy mmur...@commonsware.com wrote: On Sat, Sep 11, 2010 at 8:04 AM, Mystique joven.ch...@gmail.com wrote: So if I want to get value of UN, I do this - String temp = moveToPosition(UN)? No. c.moveToPosition(position); // where c is your Cursor String temp=c.getString(...); // where ... is whatever column number you are seeking -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to get value from ListView onListItemClick?
Cancel my last qns, I understood and get it work already :) On Sep 11, 8:32 pm, Mystique joven.ch...@gmail.com wrote: Dear Mr. Murphy, Thanks, I understood this part ok c.moveToPosition(position); // where c is your Cursor String temp=c.getString(...); // where ... is whatever column number My cursor was created in onCreate, how do I initial it in public void onListItemClick? This part I do not understand. On Sep 11, 8:19 pm, Mark Murphy mmur...@commonsware.com wrote: On Sat, Sep 11, 2010 at 8:04 AM, Mystique joven.ch...@gmail.com wrote: So if I want to get value of UN, I do this - String temp = moveToPosition(UN)? No. c.moveToPosition(position); // where c is your Cursor String temp=c.getString(...); // where ... is whatever column number you are seeking -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Possible to clear gallary cache via Android code?
Hi, I'm looking for ways to clear cache from the gallary. Can I implement code in my Android app? How to do it? (not the manual way). Many thanks. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Why Android cannot play .avi but can play youtube (avi?) and flash?
Most youtube are flash am I right? then the codec must be build in somewhere? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en