Android Development

Rapid android development from Berlin

Browsing Posts published in March, 2009

Yesterday we took part in the second ‘android stammtisch’ (meet-up) at the Oberholz in Berlin-Mitte.

It was very interesting and the topics were not just about android but about mobile development, payment methods, best practices, mobile tv, data flatrates, hardware and of course other non-android devices.
We sat along with CEOs, developers and a product manager from T-Systems international.

We talked 4 hours and where finally loaded with a lot of information. It was a great event!

If you want to participate, just join the xing group and you will be invited to the next meeting.

Share

As the developer guide says that table border lines are not displayed there is only a dirty fix for this problem:

Give the TableLayout a background color, give the TableRow another background color and set margin to the TableRow. The amount of the margin is the amount of the “border”. Same for each View in the TableRow.

A “dirty” sample:

1
2
3
4
5
6
7
8
<TableLayout android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:stretchColumns="*" android:background="#ff0000">
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <Button android:id="@+id/button" android:text="+" android:background="#0000ff" android:layout_margin="2dip"/>
        <TextView android:text="@string/label"  android:background="#0000ff" android:layout_margin="2dip"/>
        <TextView android:id="@+id/amount"  android:background="#0000ff" android:layout_margin="2dip"/>
    </TableRow>

Source: My answer on anddev.org forum

Share

While working on a little game to learn more about Intents, Activity life cycle and other stuff, I used the TableLayout for the first time. I realized that the auto-completion missed the attribute android:layout_span which is referred by the R.attr. The same with android:stretchColumns. As I read some minutes ago, some people still think column span is not possible – so I decided to publish a sample to prove them wrong.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!-- snipped -->
<TableLayout android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:stretchColumns="*">
    <TableRow>
        <TextView android:id="@+id/info"
            android:layout_span="3"
	    android:text="@string/info"
	    android:layout_gravity="center_horizontal" />
	</TableRow>
    <TableRow>
	    <Button android:id="@+id/button_add" android:text="+" />
	    <TextView android:text="@string/label" />
	    <TextView android:id="@+id/amount" />
    </TableRow>
<!-- snipped -->
</TableLayout>
<!-- snipped -->

If the auto-completion leaves out an attribute, there can be more attributes being unsupported, so always use the API as cross reference!

Share

It might be obvious linux savvy folks, but trying to access localhost or 127.0.0.1 with the android emulator in order to access a local server for testing won’t get you anywhere. That’s because the IP is used internally by the undlying linux as you might have guessed.

Luckily there’s an IP you can use to achieve hitting your local apache/tomcat/whatever : 10.0.2.2

Share

In our little sample application we used the strings.xml to define static texts.
If you want to use the build-in multi-language support you just have to follow some easy conventions.
To use localization for strings you have to add a new directory to res/ and name it “values-de” for the german language.
Create a strings.xml in this directory and deploy your application. If you now change your language on the device or emulator, the phone picks the strings.xml with the matching local code and uses it – in the same manner you could provide images etc. for a specific language (i.e. graphical buttons).
Works well for our little sample.

Our strings.xml for the german language:

1
2
3
4
5
6
7
8
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">Wähle einen Freund</string>
    <string name="button_info_text">Bitte wähle einen Kontakt aus</string>
    <string name="button_text">Auswahl</string>
    <string name="contacts">Kontakte</string>
    <string name="chosen">Sie haben ausgewählt:</string>
</resources>
Share

After working on our first list application and finally adding the user photos to our list we now want to show you how you can use your activity in another context.

This tutorial will show you how you can use a button to open the created contact list to pick a contact and display the name of the picked contact with the “Toast widget”.

The first thing you should do: create another project to be sure to have two working application samples.
Package: com.droidnova.android.samples
Activity name: PickYourDude
Application name: Pick your dude
continue reading…

Share

One of the annoyances anyone starting android development has to go through is getting hold of the android sdk sourcecode.

Surprisingly the sourcecode does not come bundled with the sdk, nor is there a way to get it seperately as an android-src.jar like with the sun sdks. To top it off, you actually can get the sources by google – but only using MacOS or *nix to check out from their repository.

Even with the recommended OS this is far from a trivial task but concerning developers using windows it’s unfriendly to say the least.
continue reading…

Share

The first part of our application could only display a default icon for each contact in our list. Now we want to change that and display the contact photo you added to your contacts on your phone.

First we start to change our main.xml. We have to remove the src attribute and add an id to the ImageView node.

1
2
3
<imageview android:id="@+id/contact_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

On line 1 the source is replaced with the id named “contact_image”.
continue reading…

Share
Powered by WordPress Web Design by SRS Solutions © 2012 Android Development Design by SRS Solutions