Merry christmas everyone

Christmas tree
Na dann will ich mich mal hier einreihen und allen ein frohes Weihnachtsfest wünschen. Geniest die Zeit :)

 

 

 

I wish everyone a merry christmas. Enjoy the best time of the year :)

Je souhaite à tous un joyeux Noël. Profitez de la meilleure période de l’année :)

Ik wens iedereen een vrolijk kerstfeest. Geniet van de beste tijd van het jaar :)

Vsem želim vesele božične praznike. Uživajte v najboljši čas v letu :)

Přeji všem veselé Vánoce. Užijte si to nejlepší čas roku :)

Życzę wszystkim Wesołych Świąt. Ciesz się najlepszą porę roku :)

Я желаю всем счаст

ливого Рождества. Наслаждайтесь лучшим временем года :)

Jeg ønsker alle en riktig god jul. Nyt den beste tiden av året :)

Les deseo a todos una Feliz Navidad. Disfrute de la mejor época del año :)

私は、みんなにメリークリスマスをお祈りしております。今年のベストタイムをお楽しみください :)

Well, I heard such a learn all languages in one night tape last night. Impressive, isn’t it? *hehe* ;o)

Merry christmas everyone :)

Windows 8 Pro with Media Center activation

Win8

The Windows 8 Pro activation of additional features is a bit dumb. Instead checking if the entered key is already used it just checks if the key is valid and then upgrades the Windows 8 Pro version to Windows 8 Pro with Media Center. Windows tries to activate the new key after the next reboot. If the key is already used your Windows isn’t activated anymore even with the bought Windows 8 Pro key. And the best of all you can’t go back. No system restore point or any other option. Just a reinstall of Windows helps.

Problem was the free MediaCenter (for a limited time) and only one key per email. So I used the same email for my desktop pc which I already used for my laptop. So I got the same key. It’s easy to get a new key with another email address but you have to wait up to three or more days until you get the new key.

Well, I got a new key and so I could reactivate Windows 8 again.

Transfer extra data to new activity but you don’t get in the new activity?!

 

If you want to transfer some extra data to the called activity you have to use the extra data within a intent. You can do it in this way:

Intent intent = new Intent(this, Activity2.class);
intent.putExtra(ActivityCategoryEdit.IDKEY, items.get(position).getID());
startActivity(intent);

You just have to read the extra data within the onCreate function in called activity. Just like that:

id = getIntent().getIntExtra(IDKEY, -1);

That works as long the transfered value is a integer. But the type of the transfered ID is long in my case and if you try this way with a long value you just get the default value (-1) in the Activity2. This cost me some time to find out why. I have to use getLongExtra to get it work. A simple change was the solution … like always ;)

Here the code for the long value in Activity2. Activity1 don’t need to be changed.

id = getIntent().getLonExtra(IDKEY, -1);

Maybe this will help you.

Dynamic tables with Android – Part II

Deleting dynamically added rows was a bit tricky at the first. I found my solution with storing the rows in ArrayList so I can easily remove them from the table. Just look at the code:

private ArrayList<TableRow> rows;

rows = new ArrayList<TableRow>();

//When creating and adding the row to the table save it also to the ArrayList
rows.add(row);

//Clear the dynamically added rows whenever we need it
private void clearTable(){
	if (rows.size() > 0)	{
		for (int i = 0; i < rows.size(); i++) table.removeView(rows.get(i));
    }
    rows.clear();
}

Adding rows to a table is described in Part I

Dynamic tables with Android


I’m developing a android app for our field staff here at work. I needed some tables for data output. First of all we need a XML layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textSample"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:text=""
        android:gravity="center"
        android:textSize="20dp"
        android:textStyle="bold" />
    <TableLayout
        android:id="@+id/tableSample"
    	android:layout_width="match_parent"
   	android:layout_height="wrap_content"
    	android:stretchColumns="0" >
    	<TableRow
    	    android:id="@+id/tableHeader" >
        	<TextView
            		android:id="@+id/labelHeader1"
        		style="@style/TableHeader"
        		android:text="@string/label_header1" />
        	<TextView
            		android:id="@+id/labelHeader2"
        		style="@style/TableHeader"
        		android:text="@string/label_header2" />
        	<TextView
            		android:id="@+id/labelHeader3"
        		style="@style/TableHeader"
        		android:text="@string/label_header3" />
        	<TextView
            		android:id="@+id/labelHeader4"
        		style="@style/TableHeader"
        		android:text="@string/label_header4" />
        </TableRow>
    </TableLayout>
</LinearLayout>

Then we need a layout for the dynamically added tablerows:

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android">
    <TextView
    	android:id="@+id/textItem1"
        style="@style/TableItem"
        android:text="" />
    <TextView
      	android:id="@+id/textItem2"
        style="@style/TableItem"
        android:text="" />
    <TextView
       	android:id="@+id/textItem3"
        style="@style/TableItem"
        android:text="" />
    <TextView
       	android:id="@+id/textItem4"
        style="@style/TableItem"
        android:text="" />
</TableRow>

I placed the styles in the values/style.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="TableHeader">
		<item name="android:layout_width">wrap_content</item>
		<item name="android:layout_height">30dp</item>
		<item name="android:layout_margin">1dp</item>
		<item name="android:gravity">center_vertical</item>
		<item name="android:padding">3dp</item>
		<item name="android:textSize">14dp</item>
		<item name="android:textStyle">bold</item>
		<item name="android:textColor">@color/default_table_header_color</item>
		<item name="android:background">@color/default_table_header_background</item>
    </style>

    <style name="TableItem">
		<item name="android:layout_width">wrap_content</item>
		<item name="android:layout_height">25dp</item>
		<item name="android:layout_margin">1dp</item>
		<item name="android:gravity">right|center_vertical</item>
		<item name="android:padding">3dp</item>
		<item name="android:textSize">14dp</item>
		<item name="android:textColor">@color/default_table_item_color</item>
		<item name="android:background">@color/default_table_item_background</item>
    </style>

</resources>

We can put these all together with some java code:

TableLayout table = (TableLayout)getActivity().findViewById(R.id.tableSample);
while (some_data_still_come_in){
	TableRow row = (TableRow)LayoutInflater.from(this).inflate(R.layout.tablerow, null);
	((TextView)row.findViewById(R.id.textItem1)).setText("some text");
	((TextView)row.findViewById(R.id.textItem2)).setText("some text");
	((TextView)row.findViewById(R.id.textItem3)).setText("some text");
	((TextView)row.findViewById(R.id.textItem4)).setText("some text");
	table.addView(row);
	get_next_data();
}
table.requestLayout();

That’s all. Works fine and you get also a table feeling with this style.