[Q] Linkify vs TextView vs setMovementMethod - Android Software Development

hi,
I'm loading a standard HTML code into a text view and would like to see the links to be possible to click and call the browser (web intent)
from all my readings the following code was supposed to work:
Code:
TextView tx = new TextView(this);
tx.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
tx.setText(Html.fromHtml(item.get_text()));
tx.setMovementMethod(LinkMovementMethod.getInstance());
mLayout.addView(tx);
but the fact is.. it does not work!
according to google API example link.java
Code:
TextView t3 = (TextView) findViewById(R.id.text3);
t3.setText(
Html.fromHtml(
"<b>text3:</b> Text with a " +
"link " +
"created in the Java source code using HTML."));
t3.setMovementMethod(LinkMovementMethod.getInstance());
it was supposed to be that simple, in it's declaration text3 have no special tags.
I tried several options using Linkify(tx, Lkinkify.ALL); tx.setClickable(true); tx.setLinksClickable(true); setAutoLinkMask(Linkify.ALL) and regardless of what combination I tried I cannot make those HTML links clickable!
important to note that every time I use setMovementMethod the underline on the links disappear from the TextView
any help please??

Have you tried just putting the html from their example in the fromHTML method? It shouldnt be any different but when stuff doesn't work its good to simplify.
Maybe your item.getText is wonky
From something awesome

Just to "close" the post.
at the end I guess was just some mixed binaries floating in my phones flash.. cause after I unistall the app, re-copy the code from the examples and tried it just worked... go figure.
in case anywant fancy.. the final code is:
Code:
TextView tx = new TextView(this);
tx.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
tx.setTextColor(getResources().getColor(R.color.txt));
tx.setLinkTextColor(getResources().getColor(R.color.txt));
tx.setMaxWidth((int) (getResources().getDisplayMetrics().density * 360));
tx.setText(Html.fromHtml(item.text));
tx.setMovementMethod(LinkMovementMethod.getInstance());
TextLayout.addView(tx);
if any forum moderator sees this feel free to close the thread.

Related

Learning how to program for Windows Mobile?

I've done some searching, and I know Windows CE uses Win32, which I know to an extent. I was curious if there are any good free resources for learning WinCE-Win32, or if I should simply use my existing books for MFC/Win32. Microsoft's site kinda sketchy, and MSDN not being very useful. I did get Microsoft Embedded Visual C++ working and compiled a test app which worked on my MDA and on the emulator.
i would just start coding
miniMFC and compact .net framework is soo close it's only
some controls and options you dont have
ortherwise it's the same thing
learning by doing and having ones fingers down and dirty
into the code is where you learn the most
Yep, that's just how I learned when I switched to coding for PPCs.
Any way here are a few major differences to start you off:
1) All API's that use strings are in UNICODE. ASCII versions were removed.
2) For most API's that have an 'ext' version the regular version was removed. Example: ExtTextOut - yes, TextOut - no.
3) When dealing with files, all paths must be absolute. No '..\file.x' and 'file.x' will give you the file in device root and not the app directory.
And here is a nice site for pocket PC specific apps:
www.pocketpcdn.com
Has articles on just about everything from making dialogs not full screen to writing today plug-ins.
levenum said:
Yep, that's just how I learned when I switched to coding for PPCs.
Any way here are a few major differences to start you off:
1) All API's that use strings are in UNICODE. ASCII versions were removed.
2) For most API's that have an 'ext' version the regular version was removed. Example: ExtTextOut - yes, TextOut - no.
3) When dealing with files, all paths must be absolute. No '..\file.x' and 'file.x' will give you the file in device root and not the app directory.
And here is a nice site for pocket PC specific apps:
www.pocketpcdn.com
Has articles on just about everything from making dialogs not full screen to writing today plug-ins.
Click to expand...
Click to collapse
I knew about how everything was Unicode. Is there an easy way to create unicode strings? I remember there was something in MFC macro like TEXT() that did something like that, but the specifics are missing. I remember there was a knowledge base article on this, but I can't find it.
Also, what's the difference between the Ext version and the non-ext versions of an app?
EDIT: Unless I'm mistaken, I just need to put my strings in _T("*string*")
Yes, you're right, this is how you write strings in your code:
Code:
WCHAR uniStr[] = L"Unicode string";
or if you are using MFC:
Code:
CString uniStr = _T("Unicode string");
and if you have a ASCII string you want converted to UNICODE
use mbstowcs function. (CString class has a built in conversion)
As for the 'ext' API's they just give you more parameters to better control the result of whatever they are doing. In desktop windows if you didn't want to call a function with 10 parameters you usually had a simpler version of it where some things were default.
Example:
Code:
BOOL TextOut(
HDC hdc, // handle to DC
int nXStart, // x-coordinate of starting position
int nYStart, // y-coordinate of starting position
LPCTSTR lpString, // character string
int cbString // number of characters
); //5 parameters
BOOL ExtTextOut(
HDC hdc, // handle to DC
int X, // x-coordinate of reference point
int Y, // y-coordinate of reference point
UINT fuOptions, // text-output options
CONST RECT *lprc, // optional dimensions
LPCTSTR lpString, // string
UINT cbCount, // number of characters in string
CONST INT *lpDx // array of spacing values
); // 8 parameters
what would be your suggestion for a newbie to learn programming for PPC?
I'm beggining to have interest in doing this but have absolutely no idea where to start.
thanks for any advise.
For complete newbies, I wrote this post a while back:
http://forum.xda-developers.com/viewtopic.php?p=209136#209136
V

VB.net help needed for an app Im halfway through writing.

Ive got to a point where Ive got to the limit of my knowledge.
(admitedly, I no pro, I just dont know how to do this)
Ive got a loop which finds out how many images are in a folder
and it makes a new picturebox for each image, sets the image
property to show that image and gives it a name, height, width,
location and parent.
My problem is I want to add a mouseclick event for each of these
items as I create them. I just dont have a clue how to do this.
Anyone got any ideas?
Ive tried this kinda thing, but it didnt work (stupid compact framework):
Code:
picturebox.MouseClicked += new MouseEventHandler(function_name);
Good Help Forum
http://www.vbforums.com/
It must work... Not sure how it is in VB.NET, but in C# it is this:
... in some method ...
PictureBox pb = new PictureBox();
.. setting properties
pb.Click += new EventHandler(PictureBox_Click);
... end of the method
private void PictureBox_Click(object sender, EventArgs e)
{
... here goes your code, the picturebox clicked is in (sender as PictureBox), event args are in e
}
Thanks for you help
Ive not managed to get anything working properly so far
but I have within the past 10 mins figured out how to get around having to do this ^_^
See, this is a autoload image:
Me.PictureBox1.Image = New System.Drawing.Bitmap("figure2.bmp")
And Example:
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/2896d5cd-06d1-4a70-a561-a2c3497e325c
I think this wouldn't have been a problem with older VB technology if it had supported WM development. By that I mean it supported object arrays and provided a method with an 'Index'. From what I can see .NET doesn't offer such a luxury.
Your code looks right (syntax); but would I be right in thinking that your loop recreates 'picturebox' each time it loops and you are trying to associate an array of 'picturebox' to a single 'MouseEventHandler' function?
Code:
picturebox.MouseClicked += new MouseEventHandler(function_name);
My method of programming .NET is pretty much trial and error so I can't say for sure, just waffling
This is an example on how i did this with c# and the paint event. You dont want the paint event but it should be easy enough to change.
private void GenerateDynamicControls(string extt)
{
PicBox = new PictureBox();
PicBox.Image = Properties.Resources.phone;
PicBox.Name = "picturebox" + extt.ToString();
PicBox.Width = 75;
PicBox.Height = 75;
PicBox.BackgroundImageLayout = ImageLayout.Center;
flowLayoutPanel1.Controls.Add(PicBox);
PicBox.Paint += new PaintEventHandler(picpaint);
}
private void picpaint(object Sender,System.Windows.Forms.PaintEventArgs e)
{
//Do whatever you need done here
}
//To Create the control do this.
GenerateDynamicControls(namethecontrolsomething);
Hope this helps.
In VB.Net, you need to use AddHandler. Quick search on the tutorial and I found, http://www.thescarms.com/dotnet/EventHandler.aspx
Hope this help.
smart device applcation
Sorry guys but I will use this thread to ask for your help regarding VB.Net.
Does anyone know how to browse the device and select a picture into a picture box?
Example:
I have a form with a picturebox and a button and what I want is by pressing the button to explore my device, choose a picture and update my picturebox with the picture selected.
There are loads of youtube videos with Windows Forms Applications tutorial but I just can not find one for a smart device applcation.
Any help?
Thanks

dynamically setting image resources

greetings
was referred to this forum from someone at androidcommunity.com regarding this...
i searched the forum but couldnt find any relevant posts - can anyone point me in the right direction for doing this properly?
specifically how could one set an image resource based on a string variable being used for part of the image's file name
i tried this based on a post i saw elsewhere:
myContext.getResources().getIdentifier(myStringVariable + "_thumbnail", "drawable", myContext.getPackageName()));
but it returnes a string(or an integer?) of numbers (the resource id?) that setImageResource couldnt use unless i just wasnt doing it properly.
is there perhaps a way to get the resource name based on that id number or whatever it is that im getting?
apreesh
33 views
dang
getIdentifier() returns int and yes, it could be used in setImageResource() method.
But why you want to set resources from strings?
because the image being set is based on user selection and is not just one image its several associated images so there is a number sequence to the image file names as well that i did not show in the snippet i posted.
but i went back and plugged some of those returned values (resources ids?) from getIdentifier() into setImageResource() and it does indeed work so thanks for that - i have an idea what i was doing wrong before but for the sake of moving on im using a different solution now - in short i am now defining each group of images as a separate class member int[] and i will probably use a switch case to plug the correct one into the gridview. its ugly, but i currently only have 11 different groups and no more than 16 images per group so it will work for now until i can study the resource object more and figure out a way to get counts of associated image resources based on a part of the resource name, like with a regular expression or something, because thats the next problem i will have to deal with if i am not pre-defining all of these arrays.
if you know of a way to do that that would be awesome but ill will probably look into it more myself once i get this app closed up and can go back and fix stuff. im pressed for time right now.
thanks
It's really bad thing to use getIdentifier() method, we should always use R class. I think your problem resides somewhere before, you try to do something, that you shouldn't
How do you get these strings? You mentioned they are from user, but he doesn't write them by hand, right? If this is some selectable list, etc., they should be ints, enums, or some objects from the beginning. Not strings. Parsing strings is always ugly.
Ahh and if you have group of many small images, it is usually better to concatenate them into one big image - it's more efficient and you don't have to use 200 R constants in your code.
the string comes from the tag associated with a clickable imageView selected from the previous screen - a menu item if you will. the string will serve several purposes, retrieving related data, etc, but the first thing i needed to work out was retrieving the correct images and displaying them. i dont know how i could concatenate the images into one big image because each one needs to be clickable itself and handle certain events associated with itself.
i will go ahead and admit this is my first app so im basically figuring stuff out as i go. and learning most of my oop from flash has probably handicapped me
i appreciate your help dude
Brut.all said:
it's more efficient and you don't have to use 200 R constants in your code.
Click to expand...
Click to collapse
the only other thing i could think of trying was creating an xml doc to group the associated resource names together and figure out how to read from that to know which images to set
i dont see any methods in the R class i could use for sorting, grouping and then retrieving certain resources based on user interaction
switch cant eval string types...!?
kadmos said:
switch cant eval string types...!?
Click to expand...
Click to collapse
Nope
As I said, strings aren't good for identifying things - regardless of the language used. This is why people created int constants and/or enums.
And no, I doubt there are some mechanisms of grouping resources, etc. It must be simple, you are trying to complicate everything
I have a strong feeling that you should change your app architecture and get rid of strings. But here quick general fix (not a good solution! but just works).
Map your strings to R ints:
Code:
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("button_normal", R.drawable.button_normal);
map.put("button_pressed", R.drawable.button_pressed);
// etc
Accessing will be done:
Code:
map.get("button_" + state); // Return int id, use as you need.
This is a bad practice, but it will work. Consider re-archirecturing your app.
@Brut.all: do you have any plans on updating apktool with 2.2 support?
@kadmos
Full example:
Code:
public static enum Planet {
MERCURY(R.string.planet_mercury, R.drawable.planet_mercury),
VENUS(R.string.planet_venus, R.drawable.planet_venus),
EARTH(R.string.planet_earth, R.drawable.planet_earth),
MARS(R.string.planet_mars, R.drawable.planet_mars);
public final int nameResId;
public final int imageResId;
public static Planet findByNameResId(int nameResId) {
for (Planet p : values()) {
if (p.nameResId == nameResId) {
return p;
}
}
return null;
}
private Planet(int nameResId, int imageResId) {
this.nameResId = nameResId;
this.imageResId = imageResId;
}
}
You have enum of planets, each of them has its name and image. Then you could do something like:
Code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
for (Planet planet : Planet.values()) {
menu.add(0, planet.nameResId, 0, planet.nameResId);
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Planet planet = Planet.findByNameResId(item.getItemId());
doSomethingWithPlanetImage(planet.imageResId);
return true;
}
You identifies planets by ints (nameResId in this example - of course it must be unique), not by strings. Operations on ints are several times faster, than on strings, this is why Google decided to identify all things: resources, menu items, etc. just by ints.
Ahh and no, writing switch-cases to do something depending on given object isn't true OOP. OOP is above: enums know, which drawable is connected to them, there is no need for switches.
AuxLV said:
@Brut.all: do you have any plans on updating apktool with 2.2 support?
Click to expand...
Click to collapse
Yeah, of course, I want to work on apktool this weekend. Unfortunately baksmali doesn't support Froyo yet, so I can't support it fully neither.
@Brut.all:
Ha, I recognise that example It's from the Java Trail/tutorial on enums isn't it? Except they used gravity rather than drawable references.
@kadmos:
Are all the images known from the beginning? In other words, is the user creating them at runtime or are you including them with your app? If they are included with your APK then normally, as Brut said, you should be able to use the identifiers directly.
Concatenating the images all into one isn't hard to do, as you can still draw the specific bitmaps out using the Bitmap.create(bitmapToGetAPartOutOf, ....) method. You can then make those individual bitmaps into ImageViews and only have to remember the 'grid reference' for where they came out of the big image. That said, you'd have to balance the added complexity of creating the big images against the ease of not having loads of R constants. I can't really say anymore because I'm not fully following what you're trying to achieve.
Steven__ said:
@Brut.all:
Ha, I recognise that example It's from the Java Trail/tutorial on enums isn't it? Except they used gravity rather than drawable references.
Click to expand...
Click to collapse
I took planets example, because it's good, but everything was written from scratch
Steven__ said:
Concatenating the images (...)
Click to expand...
Click to collapse
I'm pretty sure I saw this concatenating approach somewhere in official Android's guidelines for performance, but now I can't find it :-/ Also I don't have much experience in Android development, so if no one else suggest this approach, then I think kadmos could forget about it.
Brut.all said:
You identifies planets by ints (nameResId in this example - of course it must be unique), not by strings. Operations on ints are several times faster, than on strings, this is why Google decided to identify all things: resources, menu items, etc. just by ints.
Ahh and no, writing switch-cases to do something depending on given object isn't true OOP. OOP is above: enums know, which drawable is connected to them, there is no need for switches.
Click to expand...
Click to collapse
i know its not true oop i didnt want to have to do that but i have not yet seen a way to pass any value from a selected item into a method that could use that value to retrieve x amount of associated resources (images in this case).
Steven__ said:
Are all the images known from the beginning? In other words, is the user creating them at runtime or are you including them with your app? If they are included with your APK then normally, as Brut said, you should be able to use the identifiers directly.
...I can't really say anymore because I'm not fully following what you're trying to achieve.
Click to expand...
Click to collapse
using the planets example, say i had x (varying) amount of pics of each planet's surface in my drawables and wanted only those planet's pics to display in a grid view when a user selects whichever planet. thats really all this is. being new to this i just dont know the most efficient way to do it. if this was Flash i could just group all the images file names/paths in an external xml doc and use that to load them from whatever folder at runtime - i wouldnt need any of those 200 or so images declared as anything or even as assets in my library (and i would only need the xml because flash cant access a file system on its own to see and filter files that it would or wouldnt need based on, say, a string comparison - though there is third party software like Zinc that gives Flash that capability.)
so i did get this to work by passing a number as a tag (string) in a bundle though an imageView click event and then casting the string as an int to use in the switch - which as of now leads to one of 11 different int arrays of resources names (images) ive got declared in my ImageAdapter class to populate my gridView.
the way i wished i could made this work would have been to use a string (like a planet name) ,passed from whatever planet image/menu item/whatever was clicked, and use that string to compare and determine which and how many images in drawables were associated with that planet and then use that to create my gridView at runtime.
kadmos said:
so i did get this to work by passing a number as a tag (string) in a bundle though an imageView click event and then casting the string as an int to use in the switch - which as of now leads to one of 11 different int arrays of resources names (images) ive got declared in my ImageAdapter class to populate my gridView.
Click to expand...
Click to collapse
I see what you're saying, that makes sense. Just as a quick note though, if you're declaring your ImageViews programmatically, you don't have to use a string object for the tag. You can directly give the integer and then cast it back when you get the tag. Just remember to use (Integer) as the tag is actually just an unspecified object.
kadmos said:
the way i wished i could made this work would have been to use a string (like a planet name) ,passed from whatever planet image/menu item/whatever was clicked, and use that string to compare and determine which and how many images in drawables were associated with that planet and then use that to create my gridView at runtime.
Click to expand...
Click to collapse
Yes, I can see why you'd want to do it this way. Your current problem is that if you add more images, you have to manually update your arrays. Unfortunately I can't think of a better, 'clean' way of doing it.
@kadmos
Now I have problems understanding you ;-) But if you don't want to declare all images in sources, but in XMLs, then you could use XML arrays.
Code:
<resources>
<string-array name="planet_names">
<item>mercury</item>
<item>venus</item>
<item>earth</item>
<item>mars</item>
</string-array>
<integer-array name="planet_images">
<item>@array/mercury_images</item>
<item>@array/venus_images</item>
<item>@array/earth_images</item>
<item>@array/mars_images</item>
</integer-array>
<integer-array name="mercury_images">
<item>@drawable/mercury_0</item>
<item>@drawable/mercury_1</item>
<item>@drawable/mercury_2</item>
</integer-array>
<integer-array name="venus_images">
<item>@drawable/venus_0</item>
<item>@drawable/venus_1</item>
<item>@drawable/venus_2</item>
</integer-array>
<integer-array name="earth_images">
<item>@drawable/earth_0</item>
<item>@drawable/earth_1</item>
<item>@drawable/earth_2</item>
</integer-array>
<integer-array name="mars_images">
<item>@drawable/mars_0</item>
<item>@drawable/mars_1</item>
<item>@drawable/mars_2</item>
</integer-array>
</resources>
When user will open planet selector, you will iterate through contents of R.array.planet_names array, each item (planet) in this selector will have itemId set to array index. When user will click on something, you will get itemId of clicked item, then you will find array of its images as R.array.planet_images[itemId] (not exactly - it's conceptual example).
You will be able to add new images or even planets through XML editing.
Steven__ said:
Yes, I can see why you'd want to do it this way. Your current problem is that if you add more images, you have to manually update your arrays. Unfortunately I can't think of a better, 'clean' way of doing it.
Click to expand...
Click to collapse
Brut.all said:
But if you don't want to declare all images in sources, but in XMLs, then you could use XML arrays...
...You will be able to add new images or even planets through XML editing.
Click to expand...
Click to collapse
as i posted earlier this was the idea that i had - i havent tried it yet because i wanted to get some feedback from you guys just to see if i was completely off base. so right now its coming down to what would make for the more memory efficient final product - declaring all these images as class array constants (which i already have working) or using xml and coding the operations for parsing, counting, filtering, assigning, etc?
again thank you guys for your time and help
kadmos said:
or using xml and coding the operations for parsing, counting, filtering, assigning, etc?
Click to expand...
Click to collapse
Do you mean parsing XMLs? My example above uses standard Android resources. You don't have to parse these XMLs, you will get them as arrays And yes, it's super efficient, because they are compiled to easy-to-read form
ok then im going to go ahead and try it
be back soon
i hope

Make a google search by code

Hello, I'm trying do something but don't find the way.
My application have a button, wich on click should open the browser showing the google results for a search (Just search a string on google and show it on browser).
How can I do it? I have searched a lot but only find results unrelated with android development
Thanks!
I havent tried this but I think something like this should work:
Code:
String mySearchTerms ="is+android+awesome";
String urlString = "http://www.google.com/search?q="+ mySearchTerms;
Intent i= new Intent( Intent.ACTION_VIEW );
i.setData( Uri.parse( urlString ) );
startActivity ( i );
You could get more fancy and send them to the mobile site too, and URL encode the mySearchTerms string if you want. There should be URL encoding utils in the org.apache package.
Thanks! =)

DataManagement Library for Easy Android Database Storage

Storing objects to a Database for an Android application should be fast and easy as:
Code:
dm.add(new StorableClass());
DataManagement is a new open source library that allows you to do just that.
DataManagement is a Java Android library designed to help easily and efficiently store aggregate classes to an SQLite database. It eliminates the need to write separate classes to manage database – object interactions and allows developers to use simple methods to store, query, update, and delete objects. The library is capable of storing all objects of classes whose instance variables are either primitive data types or are themselves objects of another storable class. The DataManagement Library condenses many standard database features into several simple methods. It is fully open source and the code can be found at http://epsilonlabsllc.github.com/DataManagement
Examples:
Creating a Storable Class:
Code:
public class StorableClass{
@Id
private int ident;
private int num1;
private double num2;
private String num3;
private boolean num4;
public static final int num5 = 3;
private OtherStorableClass[] ds2;
}
A storable class must meet two requirements. First, the class must have a private instance variable of type int that will be used as the id number of the object. This variable may be read by the application, but the application should not have the capability to write to or change this variable in anyway. This variable is identified by the system with an @Id annotation. In addition, the class should not have any instance variables that are not either primitive types, strings, or other storable objects.
Instantiating a DataManager Object:
Code:
DataManager dm = new DataManager(context);
The open method accepts the calling Context that is going to use the database. Usually this should be the calling Activity.
Opening a Database for Use:
Code:
dm.open();
This method must be called before the database is used in any way.
Closing a Database After Use:
Code:
dm.close();
This method should be called after all database operations have been performed.
Adding an Object to the Database:
Code:
int id = dm.add(new StorableClass());
The add method accepts an object of a storable class as its only parameter and adds it to the database. It returns its id in the database for future use.
Retrieving a Specific Item from the Database by ID:
Code:
StorableClass storableObject = dm.get(StorableClass.class, id);
The get method accepts two parameters: the data type of the stored object and the Id number of the object (the return value of the add method).
Retrieving All Objects of a Given Type Stored in the Database as a Collection:
Code:
storableObjectCollection = dm.getAll(StorableClass.class);
The getAll method’s only parameter is the class of the objects that should be retrieved.
Retrieving a Collection of Storable Objects that match a given criteria:
Code:
Collection<StorableClass> storableObjectCollection = dm.find(StorableClass.class, 5, "num1");
The find method accepts three parameters: the data type of the stored object, the value that is being searched for, and the name of the instance variable as a string. This method is overloaded in such a way that the second parameter may be any primitive value or a string.
Updating an Object in the Database:
Code:
dm.update(id, updatedObject);
The update method accepts two parameters: The id number of the object being updated and the updated object that will replace the existing one I the database. If the id number of the new object and the id number given as the first parameter do not match, the object’s id will be overwritten.
Deleting an Object by its Id number:
Code:
dm.delete(StorableClass.class, id);
The delete method accepts two parameters: The data type and id number of the object to be deleted.
Additional Notes:
Id numbers are used by the database to ensure that objects are put in the correct place and to allow the program to access these objects. It is important that programs using this library do not attempt to set these variables as they will be initialized and managed by the library. These id numbers are unique for objects of a given type; objects of different types may have the same id number. In addition, if objects are deleted from the database their id numbers are left empty and are not reused.
Licensing:
DataManagement is Currently Licensed under the GNU General Public License, version 3 (GPL-3.0). It is intended for open source use by anyone who would like to use it.
This is awesome!!
Tried it out for an app today-- incredibly simple! For those looking-- this library essentially replaces loads of SQL helper classes and queries with an interface that's similar to ArrayList.
Definitely going to use this for everything in the future!
Thanks
Did you change the license or something? The repo is no longer on github.
regaw_leinad said:
Did you change the license or something? The repo is no longer on github.
Click to expand...
Click to collapse
After a quick search on github, it looks like it's been moved here
https://github.com/epsilonlabsllc/DataManagement
cmike21 said:
After a quick search on github, it looks like it's been moved here
https://github.com/epsilonlabsllc/DataManagement
Click to expand...
Click to collapse
Thanks. I forgot to change it. I just edited my post with the correct url.
Sounds awesome! Great work.
Gonna try it this evening.
Anyone compared the performance with db4o?
are there any performance test with other DB libraries for android? and what about the this lib vs contentproviders?
activeandroid.com
code.google.com/p/orm-droid]orm-droid
satyan.github.com/sugar/
will definitly be using this once i learn some app development! thanks for this!
Just in time...
Hello,
I'm trying to build a simple project the test and learn how this lib works, but I'me quite new in programming and I have some difficulties to understand how to use dm.
The project will be a simple song database with edittexts for song and artist. I created the storableClass as the example, but I cannot understand how to connect it with the main activity, so I can use the output of the editTexts.
1st question is: do I need to have the String variables as private? I'm thinking that must have them as public, so I can connect them with the editTexts output.
2nd: question: all these methods needed to be called from storableClass, or from main activity, after I connected the storableClass with main activity? And how I do this?
Probably with the use of context you descibed, but I cannot understand how to do it. I tried sometimes but always get errors and a specific one "The constructor DataManager(Context) is not visible".
Is there any example project' source code which use this lib to get an Idea, or can you explain the context step more extensively?
Thanks in advance and sorry for noob questions.
dancer_69 said:
Hello,
I'm trying to build a simple project the test and learn how this lib works, but I'me quite new in programming and I have some difficulties to understand how to use dm.
The project will be a simple song database with edittexts for song and artist. I created the storableClass as the example, but I cannot understand how to connect it with the main activity, so I can use the output of the editTexts.
1st question is: do I need to have the String variables as private? I'm thinking that must have them as public, so I can connect them with the editTexts output.
2nd: question: all these methods needed to be called from storableClass, or from main activity, after I connected the storableClass with main activity? And how I do this?
Probably with the use of context you descibed, but I cannot understand how to do it. I tried sometimes but always get errors and a specific one "The constructor DataManager(Context) is not visible".
Is there any example project' source code which use this lib to get an Idea, or can you explain the context step more extensively?
Thanks in advance and sorry for noob questions.
Click to expand...
Click to collapse
Here is a sample project: https://github.com/epsilonlabsllc/D.../net/epsilonlabs/datamanagementefficient/test
(It's in the github project.)
You can set the strings on private, because you can grab the values of the edittext on your layout. Eclipse should generate your set/ get methods if you create your private strings. The methods. Take the values and insert them into your db, Look at the sample:
Code:
public DataSample(){
num1 = 3;
numderp = 3.0;
num3 = "three";
num4 = true;
ds2depier = new ArrayList<DataSample2>();
ds2depier.add(new DataSample2());
ds2depier.add(new DataSample2());
}
That is the basic constructor of the DataSample class. If you do an insert like
int id = dm.add(new StorableClass());
Click to expand...
Click to collapse
The basic constructor will be called and it sets your values for example the num1 =3. You could overwrite the basic constructor with your costum constructor to insert your values.
You activity call:
dm.add(DataSample(sSong,sTitle));
Click to expand...
Click to collapse
The constructor could be something like this:
public DataSample(String sSong, String sTitle){
sYourTitleDataBaseColumnCaption = sTitle;
sYourSongDataBaseColumnCaption = sSong;
}
Click to expand...
Click to collapse
Or use the set/get methods, my custom constructor are just an idea to show you an example. Just take a closer look at the github sample and it should work for you.
Thanks, I think I can figure it out now.
How to is very outdated. I can't initialize via new DataManager() but via getInstance(), also delete and update method doesn't have Id argument anymore.
Also,
I can't get this to work. I can't even add a member to collection because it needs to use db.add(new MyClass()); but i already have MyClass() initialized with their members. I have tried to do something like copy the Id from add, update into my other instance of this class and run a db.update() but it throws a RuntimeException.
Not usable at this time.
Sounds good!
I'll give it a try as soon as I start a new project that requires data storage ...
I really hate SQLiteOpenHelper, cursor and all this strange syntax ...
The idea is good, but it can't be compared to db4o, specially when talking about documentation.
Hello mate,
I'd like to use your library and backup the data with Google/Dropbox Sync... can you tell me the name of the file on which you save data?
Thanks,
Tiwiz

Categories

Resources