Posts

Making a simple wallpaper with Inkscape

Image
Here is another good screencast on using Inkscape. This is my effort. Not as good as his, but I don't think it's too bad at all. Not sure what I would use this for though...

Using the chrome filter in Inkscape

Image
Here is another good screencast from HeathenX. So far they have all been worth watching. Now I need to think of somewhere within one of my Android apps to use this without making it look too tacky :) Here is my result having followed the tutorial.

Fake tilt and shift with Inkscape

Image
This is not exactly Android stuff. Another Inkscape screencast . This one is good too and produces a nice effect with the right photograph to start. I am telling myself that is the reason why mine does not look as good as his, but in my defence I did take my photo myself - Heathenx got his off someone else ;)

Excellent Inkscape resources

Image
Inkscape is a very powerful tool for creating vector graphics for just about any application - print or digital. I use it for a lot of my Android graphics. This screen cast is great. It shows how to illustrate a crown cap for a bottle. Here's my effort: So its not very complimentary about American beer, but you get the idea :)

Loading data into an android database

Image
AutoCompleteTextView I wanted to demonstrate how it is possible to back an AutoCompleteTextView  with data from a database Cursor. To do this I needed to put a few thousand rows of data into the SQLite database on the device. I got my list of words here: http://www.wordlistgenerator.net/ I just left it with the default options to give me a nice long list. I took the apostrophes out to avoid having to escape them - I am only looking for semi junk input afterall. Location of 'words' file I saved the list into a file called 'words'. Note that there is no extension here. I am going to use this as a resource in Android and the extension interferes with this. I dropped the file into my res/drawable folder (as good as any) in order to be able to access it with my load method below. Then I used the following code to load the rows from words into the database: public void load() { SQLiteDatabase db = getReadableDatabase(); try { InputStream is =...

AutoCompleteTextView backed with data from SQLite in Android

Image
This is a handy piece of code. As your database gets bigger you can allow the user to pick the correct value by typing. If the db gets very big, you can always increase the threshold, so that the query does not run until there will be a suitably sized resultset returned. Running it at a threshold of 1 is fine for very small resultsets.  Here is the code you need to back your AutoCompleteTextView with a cursor adapter. @Override protected void onResume() { super.onResume(); text = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1); final AdapterHelper h = new AdapterHelper(this); Cursor c = h.getAllResults(); startManagingCursor(c); String[] from = new String[] { "val" }; int[] to = new int[] { android.R.id.text1 }; CursorAdapter adapter = new MyCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, c, from, to); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(Cha...

Custom RadioButton with new XML attributes on Android

Image
The 'conversion' RadioButtons I am building an app to log a users Pedometer steps. It has a set of RadioButtons for different sports. By clicking on these buttons the user can choose a conversion ratio to steps. This allows them to take part in a variety of sports and still count them as 'steps' toward their goal. I wanted it to be easy to add new sports to the list without having to do any database work, or other programming. The way I chose was to extend RadioButton to take another XML attribute for conversion factor. This would be read from the file on construction of the button and could then be applied to any value entered. This is what the new class looks like: public class ConversionRadioButton extends RadioButton { private float conversion = 1.0f; public ConversionRadioButton(Context context, AttributeSet attrs) { super(context, attrs); conversion = Float.parseFloat(attrs.getAttributeValue( "http://schemas.android.com/apk/res/ie.n...