Search

Wednesday, 7 December 2016

All In one [ splash screen ,time picker ,date picker , scroll layout , intent ,tween animation]

All in One

Activity_main.xml



    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:background="@drawable/shape">

        <LinearLayout

            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            
             >

    
</LinearLayout>
    </ScrollView>


Activity_second.xml



    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="50dp"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="Enter Name" >

              
            </EditText>

            <EditText
                android:id="@+id/mail"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
               android:hint="Email Address"
                android:inputType="textEmailAddress" />
         
<TimePicker 
     android:layout_width="match_parent"
                android:layout_height="wrap_content"
                
                android:id="@+id/tp"/>
<DatePicker
   android:layout_width="match_parent"
                android:layout_height="wrap_content"
                  android:id="@+id/dp"/>
            <Spinner android:entries="@array/str"
                  android:id="@+id/Stream"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
            <TextView 
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Gender" />
            <LinearLayout       
                android:layout_width="match_parent"
            android:layout_height="match_parent"
           
            android:orientation="horizontal"  >
            <RadioGroup android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/rg">

<RadioButton
   android:id="@+id/m"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Male" />

<RadioButton
   android:id="@+id/f"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Female" />
                
            </RadioGroup>
            
            </LinearLayout>
            <TextView 
   android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Lang"/> 
<LinearLayout       
                android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/darker_gray"
            android:orientation="horizontal"  >
<CheckBox 
   android:id="@+id/g"
   android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Guj"/>
<CheckBox 
   android:id="@+id/h"
   android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hindi"/>
<CheckBox 
   android:id="@+id/e"
   android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="English"/>
</LinearLayout>

<LinearLayout       
                android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/darker_gray"
            android:orientation="horizontal"  >
<Button  
    android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:id="@+id/submit"/>
<Button   
   android:text="Reset"
   android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Clear"/>
</LinearLayout>

      
</LinearLayout>
    </ScrollView>



Activity_third.xml


    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
 <RelativeLayout 
     android:layout_width="match_parent"
        android:layout_height="match_parent">
 <Button
        android:id="@+id/time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text="Button" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/time"
        android:text="Rotate" 
        android:onClick="rotate"/>

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button1"
        android:layout_alignBottom="@+id/button1"
        android:layout_toRightOf="@+id/button1"
        android:text="Translate"
        android:onClick="translate" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button2"
        android:layout_alignBottom="@+id/button2"
        android:layout_toRightOf="@+id/button2"
        android:text="Alpha"
        android:onClick="alpha" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button3"
        android:layout_alignBottom="@+id/button3"
        android:layout_toRightOf="@+id/button3"
        android:text="Scale" 
        android:onClick="scale"/>

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button2"
        android:layout_below="@+id/button2"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="99dp"
       
        android:src="@drawable/ic_launcher" />
        </RelativeLayout>
    </ScrollView>


MainActivity.java

package com.example.allinone;

import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int secondsDelayed = 1;
        new Handler().postDelayed(new Runnable() {
                public void run() {
                        startActivity(new Intent(MainActivity.this, Second.class));
                        finish();
                }
        }, secondsDelayed * 1000);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

}

Second.java


package com.example.allinone;



import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.Spinner;
import android.widget.TimePicker;
import android.widget.TimePicker.OnTimeChangedListener;
import android.widget.Toast;

public class Second extends Activity {
Button sbmt,clear;
EditText name,mail;
DatePicker dp;
TimePicker tp;
Spinner sp;
RadioGroup rg;
RadioButton m,f;
CheckBox g,h,e;
String nm,ml,dt,tt,str,gen,lang,tm;
@Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_second);
  sbmt=(Button)findViewById(R.id.submit);
  clear=(Button)findViewById(R.id.Clear);
  name=(EditText)findViewById(R.id.name);
  mail=(EditText)findViewById(R.id.mail);
  dp=(DatePicker)findViewById(R.id.dp);
  tp=(TimePicker)findViewById(R.id.tp);
  sp=(Spinner)findViewById(R.id.Stream);
  rg=(RadioGroup)findViewById(R.id.rg);
  g=(CheckBox)findViewById(R.id.g);
  h=(CheckBox)findViewById(R.id.h);
  e=(CheckBox)findViewById(R.id.e);
 
  sbmt.setOnClickListener(new View.OnClickListener() {
 
   @Override
   public void onClick(View arg0) {
    // TODO Auto-generated method stub
   nm=name.getText().toString();
   ml=mail.getText().toString();
   dt=dp.getDayOfMonth()+"/"+dp.getMonth()+"/"+dp.getYear();
   tp.setIs24HourView(false);
   tt=getTime();
   tp.setOnTimeChangedListener(new OnTimeChangedListener() {
   
    @Override
    public void onTimeChanged(TimePicker arg0, int arg1, int arg2) {
     // TODO Auto-generated method stub
      tt=getTime();
      Toast.makeText(getApplicationContext(), ""+tt, 50).show();
    }
   
   });
 
 
 
   int id=rg.getCheckedRadioButtonId();
   if(id == R.id.m)
    gen="Male";
   else
    gen="Female";
   Toast.makeText(getApplicationContext(), "Gen : " + gen, 50).show();
   str=sp.getSelectedItem().toString();
 
   if(g.isChecked() && h.isChecked() && e.isChecked()){
    lang=g.getText()+","+h.getText()+","+e.getText();
   }else if(  h.isChecked() && e.isChecked())
    {
    lang=h.getText()+","+e.getText();
    }
   else if(g.isChecked() &&  h.isChecked() ){
    lang=g.getText()+","+h.getText();
 
   }
   else if(g.isChecked() &&  e.isChecked() ){
    lang=g.getText()+","+e.getText();
 
   }
   else if(g.isChecked() ){
    lang=g.getText().toString();
   }
   else if(e.isChecked() ){
    lang=e.getText().toString();
   }else if(h.isChecked() ){
    lang=h.getText().toString();
   }
   else{
    lang="Un Educated";
   }
   Log.e("intent pahela" ,"pass");
   Intent i=new Intent(getApplicationContext(),Third.class);
   i.putExtra("name", nm);
   i.putExtra("mail", ml);
 
   i.putExtra("date", dt);
   i.putExtra("time", tt);
   i.putExtra("gender",gen);
 
   i.putExtra("stream",str);
   i.putExtra("lang",lang);
   startActivity(i);
 
 
  }
  public String getTime(){
   tm=tp.getCurrentHour()+":"+tp.getCurrentMinute();
   return tm;
  }
 
  });
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.activity_second, menu);
  return true;
 }

}

Third.java


package com.example.allinone;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

public class Third extends Activity {
Button time;
ImageView iv;
Button r,t,s,a;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_third);
  s=(Button)findViewById(R.id.button4);
  a=(Button)findViewById(R.id.button3);
  t=(Button)findViewById(R.id.button2);
  r=(Button)findViewById(R.id.button1);
  time=(Button)findViewById(R.id.time);
  iv=(ImageView)findViewById(R.id.imageView1);
 Bundle b;
 b=getIntent().getExtras();
 Log.e("intent pachi" ,"pass");

 String n=b.getString("name").toString();
 String m=b.getString("mail").toString();
 String g=b.getString("gender").toString();
 String d=b.getString("date").toString();
 String t=b.getString("time").toString();
 String s=b.getString("stream").toString();
 String l=b.getString("lang").toString();

 time.setText("Name : " + n + " \n Gen : " + g+ " \n Mail : " + m + " \n Date : " +  d + " \n Time : " + t + " \n Stream : " + s + " \n Language : " + l + " \n ") ;


 }
 public void rotate(View v){
  Animation anim=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.r);
  iv.startAnimation(anim);
 }
 public void translate(View v){
  Animation anim=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.t);
  iv.startAnimation(anim);
 }
 public void alpha(View v){
  Animation anim=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.a);
  iv.startAnimation(anim);
 }
 public void scale(View v){
  Animation anim=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.s);
  iv.startAnimation(anim);
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.activity_third, menu);
  return true;
 }

}


Animatoin Files


a.xml {alpha}

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
   
    <set>
 <alpha android:fromAlpha="0.5"
     android:toAlpha="1"
     android:duration="2000"
     android:startOffset="2000"
     >

 </alpha>
</set>
</set>


r.xml {rotate}

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<set><rotate
    android:fromDegrees="0"
    android:toDegrees="360"
    android:duration="4000"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="infinite">

</rotate>
</set></set>

s.xml {scale}

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
   
    <set>
        <scale
            android:toXScale="1"
            android:fromYScale="0.5"
             android:toYScale="1"
            android:fromXScale="0.5"
           
         
            android:duration="2000"
            android:repeatCount="infinite"/>
    </set>
</set>

t.xml {translate}

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
   
    <set>
<translate android:fromXDelta="0%p"
    android:toXDelta="75%p"
    android:duration="800"
    >
</translate>

</set></set>


all in one


all in one

all in one




No comments:

Post a Comment