Tuesday, 17 December 2013

android button example

In this post we are going to see how to create a simple android application that contains two buttons and how to create the response for the button clicks.
Create a new android project named ButtonDemo in eclipse.
In  the activity_main.xml add two buttons as shown bellow.
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="clickMeMethod"
android:text="@string/first_button" />
<Button
android:id="@+id/bn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button2"
android:layout_centerHorizontal="true"
android:layout_marginTop="39dp"
android:text="Click me too" />
</RelativeLayout>

Now made the following changes in the MainActivity.java file which is on the package coming under the Src folder.
 package com.buttondemo;  
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button)findViewById(R.id.bn);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), "You click the CLICK ME TOO button", Toast.LENGTH_LONG).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void clickMeMethod(View v)
{
Toast.makeText(getBaseContext(), "You just click CLICK ME button", Toast.LENGTH_LONG).show();
}
}

Save the project and run.
android create buttonandroid button tutorial




Ads by Google




Monday, 16 December 2013

create your first android app

In this post i explain how to create your first android application. I use the eclipse ide for the development purpose.
See this article for the installation and configuration of eclipse for android.

Create a new android application project with name HelloWorld. (Click the image to enlarge.)
hello-world-android-app

Now on the activity_main.xml file add a new TextView as shown bellow.
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/greeting_message"
/>
</RelativeLayout>

There is no need to make any other changes on the project. Right click the project and select run as android application to run the application.
create-android-app



Ads by Google



How To Add Snow In The Background of Your Blog Using CSS

Today we’re going to go over a super simple CSS technique that you can use to make it snow on your Blogger blog. It seems particularly attractive since it doesn't require scripts, only CSS and three small images.

An advantage of this method is that by not using scripts doesn't overload the blog, the disadvantage being that users with not so modern browsers, will not be able to see it (in Internet Explorer works for version 10 and up).

The snow will fall in the background of the blog, which, in addition, prevent interfering with links or content (because the flakes are images), also prevent blocking the visibility of the content of the blog.

falling snow, snow, winter background, blogger



How To Add Falling Snow To Blogger Blogspot

Step 1. Go to "Template" and click on the "Edit HTML" button:


Step 2. Click the small arrow on the left of <b:skin>...</b:skin> to expand the style (screenshot 1) and click anywhere inside the code area to search by using the CTRL + F keys for the ]]></b:skin> tag (screenshot 2)

Step 3. Add the following code just above it:
/* Snow falling for Blogger
----------------------------------------------- */
@keyframes snow {
0% {background-position: 0px 0px, 0px 0px, 0px 0px;}
100% {background-position: 500px 1000px, 400px 400px, 300px 300px;}
}

@-moz-keyframes snow {
0% {background-position: 0px 0px, 0px 0px, 0px 0px;}
100% {background-position: 500px 1000px, 400px 400px, 300px 300px;}
}

@-webkit-keyframes snow {
0% {background-position: 0px 0px, 0px 0px, 0px 0px;}
100% {background-position: 500px 1000px, 400px 400px, 300px 300px;}
}

@-ms-keyframes snow {
0% {background-position: 0px 0px, 0px 0px, 0px 0px;}
100% {background-position: 500px 1000px, 400px 400px, 300px 300px;}
}

#falling-snow {
background-image: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA-RrzlnTpZag23K48OXBICMLZtrvFRNuE1pRt3mJUuurWURyw9fQV4eP2PZXMQAUBWnC60ISiR-fH2TqiaiAaR2lJereBOrN2G06VX-cY9BbUkKbJV7_qt2-bw4jpOztuuSiYnB9l7OLV/s1600/snow.png), url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUKYAcOpJ6T970_twppXSmrdUS6BkKWf5vvD7p2wg-PThr7N5Monrf3BzzbJYDqQwRRIk3YnGKZhhhthiEiq4vBC5W7oUtqQGaMiKPCE64lgFL_9LMZHqcNxY-qa619ScGTXA4Abbxz3G4/s1600/snow3.png), url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCc6yXIqH8pbKDX7yuSVR63IbzS9fy6ZxeDJ37DaId9ChaZu25y8r94O7MMDEAo_Gg7IrtZYLNI8XPH5tac7Dq06NzoJ4BLEGrbXQ55L7zSgcL1fVsYP7k10PwIipl0WSWedx33nZHxmDb/s1600/snow2.png);
-webkit-animation: snow 20s linear infinite;
-moz-animation: snow 20s linear infinite;
-ms-animation: snow 20s linear infinite;
animation: snow 20s linear infinite;
}
Screenshot 1:


Screenshot 2:


Step 3. Now, search (CTRL + F) the <body> tag or if you can't find it, search this line below:
<body expr:class='&quot;loading&quot; + data:blog.mobileClass'>
Step 4. Just below the tag, add this:
<div id='falling-snow'>
Step 5. Finally, find the closing </body> tag and add this tag just above it:
</div>
Step 6. Save the changes and that's it. Enjoy! :)

As you can see this tricks is very simple and easy to install, does not block the visibility of blog's content and most important, it has no scripts, only CSS and nothing else.

Saturday, 14 December 2013

Tales of Maj'Eyal (ToME) version 1.1.0 and Steam edition

The great roguelike RPG Tales of Maj'Eyal (ToME) is available as a new version (1.1.0) nicknamed "Full Steam Ahead". Here is a slightly older trailer for version 1.0.5.:



Release highlights:

  • New necromancer tree: Animus
  • All achievements now feature beautiful 128x128 images
  • Improved Alchemist interaction with its golem
  • Tons of fixes and balance adjustements
  • Many improvements for addon creators, including a way to enable debug mode and a tool (inthe debug menu) to register and upload addons to te4.org directly from the game.
  • Includes a Fez. Fezzes are cool!
Interestingly it has also been "greenlit" on the popular game distribution channel Steam, so if you want to donate to the developers you can also do it by buying ToME through this channel. The currently discounted version includes a DLC with an updated UI (and the hint for a Steampunk themed extension) which seems to me like a planned way of funding the development of the game in the future.

Friday, 13 December 2013

How to show AdSense ads that are non-standard sizes

This QuickTip is about AdSense's new custom-size-advertisement option, which lets you choose the height and width of each advertisement that you show on your site.


quick-tips logo
Today, AdSense announced that we can now make ad-units in any size that we want - within certain restrictions.  

They don't use the phase in the text of their announcement, but the post-URL for their says that this feature is  "the-next-evolution-of-responsive-ads" - so I guess it can be seen as part of the efforts to cater to mobile-readers and mobile site-publishers, even though these ads themselves don't adapt to according to the size of your visitor's screen.


What will custom-size text ads look like:

For text ads, AdSesne, will work out the best number of text ads to show in each ad-block, and the individual ads will be shown the same way they that the look inside the standard ad-sizes.

Note that they say
"For unique ad unit sizes, our system will need some time before it can optimize the number of ads shown."

My guess is that this means that initially they will just fit a standard text-unit ad within your custom size, but may manage to figure how how to fit in more content over time, as they observe what display options make most money for you (and thus for them).


What will custom-size display ads look like:

For display ads (ie ones that show pictures which the advertiser has created), AdSense will work out the best size ad to show in the custom space that you select; the only guarantee is that "the selected ad will not be larger than the space requested".

There are some accompanying  rules about maximum and minimum AdSense ad-unit sizes, and any custom ad size that doesn't satisfy these restrictions simply won't appear on a page.  These rules may change (so do go and check the official version) - but to start with they say that:
  • Only one dimension can be greater than 300 pixels
  • The minimum width is 120 pixels
  • The minimum height is 50 pixels
  • Neither height nor width can exceed 1200 pixels.

One more point:   a while after the 300x600 ad-unit was introduced, they also added a rule saying there could be no more than one of these units per page.   With custom ads, they simply say:
As always, please use your best judgement when using custom-sized ad units; ad units similar in size to the 300x600 ad format will be subject to similar placement restrictions.


How to create a custom-sized AdSense advert for Blogger

  1. Log into www.adsense.google.com using your AdSense account.
  2. Start to create an ad unit in the usual way,
  3. Select "Custom ad size" from the Ad size drop-down and enter the width and height that you want for for your ad unit.
  4. Copy and paste the ad code into the HTML source code provided by AdSense, and add it to your blog in the usual way.


Note: you will only be able to do this if you have gone through the full AdSense sign-up process. If you do not have a custom-domain and signed up for AdSense after the fast-track process for hosted-content was introduced, then your only option is to choose standard ad-sizes from the regular Add-a-gadget > Adsense process.