For smart Primates & ROBOTS (oh and ALIENS ).

Friday, August 30, 2013

Blink Text in Android

Blink Text in Android




1) create a folder in res named "anim"
under this create a blink.xml file as listed below:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha android:fromAlpha="0.0"
        android:toAlpha="1.0"
        android:interpolator="@

android:anim/accelerate_interpolator"
        android:duration="600"
        android:repeatMode="reverse"
        android:repeatCount="infinite"/>
</set>





in MainActivity

private Animation animBlink;
protected void onCreate(...) {
 textView1 = (TextView) findViewById(R.id.textView1);
 animBlink = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.blink);
 animBlink.setAnimationListener(this);
 textView1.startAnimation(animBlink);
}




Share:

Change text background color in android

Change text background color in android

static Handler h;
protected void onCreate() {
this.h = new Handler() {
    public void handleMessage(Message msg) {
        switch (msg.what) {
                case 0:
        Random rnd = new Random();
            int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
            txtMessage.setBackgroundColor(
color);
                break;
               }
               super.handleMessage(msg);
           }};
    ChangeBGColor u =new ChangeBGColor("", "");
        new Thread(u).start();
}

in other class

import android.os.Message;
public class ChangeBGColor implements Runnable {
 public ChangeBGColor(String inputFileName,String surl) {
 }
 @Override
 public void run() {
  boolean ans=false;
  int cc=0;
  while(ans!=true) {
    try {
    Thread.sleep(2000);
    Message message= new Message();
    cc++;
    message.obj = " "+cc;
    cc--;
    MainActivity.h.sendMessage(message);
    } catch(Exception ee) { }
  }
}
}
Share:

Rotate any text in android


Rotate any text in android

////// Rotate any text ///////////////////////////
static int flag=0;
private Handler mHandler;
final Context context=this;
RelativeLayout.LayoutParams par;
private int mCount = 0;
protected void onCreate() {
mHandler = new Handler();
mHandler.post(mCountUpdater);


}
private Runnable mCountUpdater = new Runnable() {
// private int mCount = 0;
@Override
public void run() {
rotate();
flag++;
mCount++;
if(mCount>=360) {
mCount=0;
}
mHandler.postDelayed(this, 1);
}
};
public void rotate() {
txtMessage.setRotation(


mCount);

}
Share:

Namespace in PHP

Namespace in PHP



<?php
namespace foo;
class Robot {
    static function says() {echo 'I am Terminator!';}
    }
?>
  
<?php
namespace bar;
class RoboCop {
    static function says() {echo 'I am Robocop!';}
    }
?>
  
<?php namespace terminate;
    class Terminator {
    static function says() {echo 'Terminator';}  }
?>

<?php namespace computer;
    class Comp {
    static function show() {echo 'I am computer';}
    function laptop() { echo "this is laptop ";}
    }
?>

  
<?php
//use foo as robo;
//use bar as roboc;
//use terminate;
//echo robo\Robot::says(), "<br />\n";
//echo roboc\RoboCop::says(), "<br />\n";
//echo terminate\Terminator::says(), "<br />\n";


echo \foo\Robot::says(), "<br />\n";
echo \bar\RoboCop::says(), "<br />\n";
echo \terminate\Terminator::says(), "<br />\n";
echo \computer\Comp::show(), "<br />\n";
$comp = new \computer\Comp();
$comp->laptop();
 

  ?>
Share:

Drag and Drop in html

Drag and Drop in html

<!DOCTYPE HTML>
<html>
<head>
<title>DRAG AND DROP </title>
<style type="text/css">
.box {width:300px
;height:350px;
border:3px solid #009966;}
</style><script>
function allowDrop(ev)
{ev.preventDefault();
}

function drag(ev)
{
ev.dataTransfer.setData("Text"
,ev.target.id);
}

function drop(ev)
{
ev.preventDefault();
var data=ev.dataTransfer.getData("Text");
ev.target.appendChild(document.getElementById(data));
}
</script>

</head><body>
<p>If you are human then Drag the image to the box </p>
<!--<div class="box" ondrop="drop(event)" ondragover="allowDrop(event)"></div>-->

<div class="box" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<br>
<br>
<img id="drag1"  src="alien.png" draggable="true" ondragstart="drag(event)" width="200" height="200">

<footer> Drag and Drop in html</footer>
</body>
</html>
Share:

Featured Post

Core Web Vitals Assessment showing LCP 10.6s while google pagespeed report showing LCP 3.5s why?

Core Web Vitals Assessment showing LCP 10.6s while google pagespeed report showing LCP 3.5s why? So, you can face this situation while...

Ads Inside Post

Powered by Blogger.

Arsip