Tuesday, June 27, 2017

HTML Menu

HTML Menu sample program tutorial.


Below code is very simple menu code with css (Cascading Style Sheet)

Code:

<html>
  <head>
    <link rel="stylesheet" href="hyper.css" type="text/css">
  </head>
  <body>
    <a href="a.html">Home</a> | <a href="b.html">Login</a>
  </body>
</html>

Explanation

It will look like this



when clicking on home it will redirect to a.html and when clicking on another menu login it will redirect to b.html.



How to refresh webpage using meta tag to another webpage



Meta Tag Sample Program to refresh webpage and redirect to 
targeted webpage


<! DOCTYPE HTML>
<html>
   <head>
      <title>
         Meta tag 
      </title>
<meta http-equiv="refresh" content="7;url=D:\ASPDoTNet Practical\a.html">
   </head>
   <body>
      hello world
   </body>
</html>


Explanation
Here in this html code meta tag refresh web page in 7 second 
and redirect to a.html page.

Wednesday, April 19, 2017

Android Simple Calculator Source Code

"Android Simple Calculator Source Code", Edit main.xml file and activity file..!Below I addressed two file main.xml and P1Activity.java file for simple android calculator source code, You can easily copy and paste this code into your eclipse or android studio.

main.xml

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

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/n1"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <EditText
        android:id="@+id/ed1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="number" >

        <requestFocus />
    </EditText>

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/n2"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <EditText
        android:id="@+id/ed2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="number" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/a"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <EditText
        android:id="@+id/ed3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="number" />

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >



            <Button
                android:id="@+id/pluse"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/pluse" />


            <Button
                android:id="@+id/min"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/minus" />

            <Button
                android:id="@+id/mul"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/mul" />
            <Button
                android:id="@+id/div"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/div" />

        </TableRow>

    </LinearLayout>

</LinearLayout>
P1Activity.java

package com.p1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class P1Activity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
 EditText ed1,ed2,ed3;
 Button pluse,min,mul,div;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ed1=(EditText)findViewById(R.id.ed1);
        ed2=(EditText)findViewById(R.id.ed2);
        ed3=(EditText)findViewById(R.id.ed3);
        pluse=(Button)findViewById(R.id.pluse);
        min=(Button)findViewById(R.id.min);
        mul=(Button)findViewById(R.id.mul);
        div=(Button)findViewById(R.id.div);
        pluse.setOnClickListener(this);
        min.setOnClickListener(this);
        mul.setOnClickListener(this);
        div.setOnClickListener(this);
        
    }
 public void onClick(View arg0) {
  // TODO Auto-generated method stub
  
  String st1=ed1.getText().toString();
  String st2=ed2.getText().toString();
  int p=Integer.parseInt(st1);
  int r=Integer.parseInt(st2);
  
  if(arg0.getId()==R.id.pluse)
  {
   double a=p+r;
   
   ed3.setText(""+a);
   
  }
  else if(arg0.getId()==R.id.min)
  {
   double a=p-r;
   
   ed3.setText(""+a);
   
  }
  else if(arg0.getId()==R.id.mul)
  {
   double a=p*r;
   
   ed3.setText(""+a);
   
  
  }
  else if(arg0.getId()==R.id.div)
  {
   double a=p/r;
   
   ed3.setText(""+a);
   
  }
  else
  {
   
  }
 }
}