Monday, August 23, 2010

AlertDialog with single selection & no radio button

Current Android version AlertDialog.Builder default behavior of "setSingleChoiceItems" creates a list with radio buttons from which you can select.

I wanted to get this list without the radio button. After digging a bit in AlertDialog.Builder & AlertController.AlertParams I found the solution: instead of using setSingleChoiceItems use setAdapter.

ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.select_dialog_item, itemActionsList);
new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
// Do something

Android hangs: "Waiting For Debugger"

I developed an application that worked just fine, and then it started to hang with the message: "Waiting For Debugger". Even when I disconnected the device from the computer the application insisted that it's waiting for the debugger...

1. Restart Eclipse [it's probably not needed].
2. Restart the Android device.

Friday, August 20, 2010

Android requires .class compatibility set to 5.0. Please fix project properties.

I've created a new workspace in Eclipse & imported an Android project.

* Issue #1:
Android requires .class compatibility set to 5.0. Please fix project properties.

* Solution:
1. Fix project:
Package Explorer ->
Right click the project ->
"Android Tools" -> "Fix Project Properties"
2. Restart Eclipse:
"File" -> "Restart"

* Issue #2: The following error appears many times
The method xyz() of type ABC must override a superclass method

* Solution:
1. Fix the project again:
Package Explorer ->
Right click the project ->
"Properties" -> "Java Compiler" -> "Compiler Compliance Level" = 1.6

Monday, August 16, 2010

DataView RowFilter performance

I needed to use DataView but the performance I got was very poor. Searching the web I found this resource which explains the root cause for this issue: after each RowFilter the DataView is re-indexed.

Searching a bit more yield the answer from Microsoft: don't use RowFilter if you don't have to. Use FindRows.

For my scenario, using FindRows instead of Row filter resulted in at least factor of 6 improvement (i.e. 1 second instead of 6).

Thursday, August 12, 2010

Eclipse hangs during building Android projects workspace

Problem: Eclipse kept on hanging during auto-building Android projects.
I found a resource which said (escalating solutions):
1. Clean the projects.
2. Create a new workspace & import all projects.
3. Reinstall Eclipse

After trying 1 & 2, I found the following weird solution:
- Remove the auto-build (Project => Build Automatically). Kill the Eclipse (since it hangs...)
- Restart Eclipse.
- Delete the 'gen' folder of all the projects (using the Package Explorer)
- Project => Clean (clean all projects)
- Build the projects

Don't know why it worked (at least until now).

Android/Eclipse: Project 'MyProject' is missing required source folder: 'gen'

I'm having lots of problems with my Eclipse (when I'll solve them I'll write about it).

Anyhow, after creating a new project in a new workspace I get the following error:
Project 'MyProject' is missing required source folder: 'gen'
After building the project there's a second error:
The project cannot be built until build path errors are resolved

A temporary solution: in the Package Explorer delete gen folder. Rebuilding the project again will fix the problem. Why it's temporary? you'll have to do it with every new project.

Thursday, August 5, 2010

Starting android calculator programmatically

Here goes:

public static final String CALCULATOR_PACKAGE =
public static final String CALCULATOR_CLASS =

public static void OpenCalculator(Context context) {
Intent i = new Intent();

i.setComponent(new ComponentName(