Monday, April 29, 2013

Button Animation android



Button Animation android
create folder anim in res folder
then create xml file name anim_rotate.xml

paste this to anim_rotate.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="500"
android:startOffset="0"
android:repeatCount="1"
android:repeatMode="reverse" />
</set>


now declare this in Activity

final Animation animRotate = AnimationUtils.loadAnimation(this, R.anim.anim_rotate);

Button b1 = (Button)findViewById(R.id.button);
b1.startAnimation(animRotate);

Friday, April 26, 2013

Tuesday, April 16, 2013

set package install location android


set application install location android
set install location to sdcard android

put android:installLocation="preferExternal"

under <manifest xmlns:android="http://schemas.android.com/apk/res/android">
in menifest.xml file


code should appears like

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="preferExternal">

for setting install location to phone put "preferInternal" in place of "preferExternal"

Create Transparent button android



make button transprent android
android transparent button


put this in xml file of button

android:background="@android:color/transparent"

all screen supporting android


to support all size screens in android


<supports-screens android:smallscreens="true">
<supports-screens android:normalscreens="true">
<supports-screens android:largescreens="true">
<supports-screens android:anydensity="true">
<supports-screens android:anydensity="true"
android:resizeable="true">


put these in manifest.xml

Disable back button android


Disable back button
disable home button android


@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
boolean i = false;
if ((keyCode == KeyEvent.KEYCODE_BACK)) {

i=true;
}
return i;
}



to disable home button put KEYCODE_HOME

Monday, April 15, 2013

Android home button


perform task on press home button


or close activity on press home button android

@Override
protected void onPause()
{
super.onPause();
finish();
this.finish();
System.exit(0);
// insert here your instructions
}

Thursday, April 4, 2013

Create alert dialog box android


create stylish alert dialog box android
create about us page android

Button b5;
b5=(Button)findViewById(R.id.aboutus);
b5.setOnClickListener(new OnClickListener() {

@SuppressWarnings("deprecation")
public void onClick(View v) {
// TODO Auto-generated method stub

AlertDialog alertDialog = new AlertDialog.Builder(
easyselect.this).create();

// Setting Dialog Title
alertDialog.setTitle("Europa TechnoSoft pvt. ltd");

// Setting Dialog Message
alertDialog.setMessage("Europa Technosoft was initially set up as" +
" a single product company at New Delhi, today it is a multi-product " +
"and multi-technology with its marketing network spread across the country." +
" The Company over the yearÂ’s mirrors and advances in technological innovations," +
" with which it has kept pace. The Company's efforts for business excellence" +
" has been recognized time and again by its customers & others.");

// Setting Icon to Dialog
alertDialog.setIcon(R.drawable.tick);

// Setting OK Button
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {


}
});

// Showing Alert Message
alertDialog.show();

}
});


Download Image tick.png here

how to make button unclickable if radio button is not selected

button.setEnabled(false);

Timer in android


How to set coundown timer in android
reverse countdown android

first declare textview


TextView tv = (TextView)findViewById(R.id.textView1);


new CountDownTimer(30000, 1000) {

public void onTick(long millisUntilFinished) {
tv.setText("Seconds remaining: " + millisUntilFinished / 1000);
}

public void onFinish() {
tv.setText("done!");
}
}.start();


timer for 30 sec.. is ready