Wednesday, 28 August 2019

Android Programming - Webview

 D:\MyApplication9\app\src\main\res\layout\activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<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"
    tools:context=".MainActivity">


    <WebView
        android:id="@+id/W1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</RelativeLayout>


**************************************************************************
D:\MyApplication9\app\src\main\java\com\ldc\myapplication\MainActivity.java

package com.ldc.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
public class MainActivity extends Activity {
WebView wv1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        wv1=(WebView) findViewById(R.id.W1);
        wv1.loadUrl("https://jchanpro.blogspot.com/");
    }
}





**************************************************************************

D:\MyApplication9\app\src\main\AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.ldc.myapplication">
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Tuesday, 27 August 2019

Android Programming Simplified one

D:\chandreadymadeshop\app\src\main\res\layout\activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"    
android:layout_width="match_parent"   
 android:layout_height="match_parent"   
  android:background="@drawable/chandra">
    <LinearLayout      
   android:layout_width="match_parent"    
       android:layout_height="match_parent"   
         android:orientation="vertical">

        <TextView         
  android:id="@+id/TV1" 
  android:layout_width="wrap_content"  
 android:layout_height="wrap_content"  
  android:text="Select Whatever you Want !!"     
  android:textColor="@android:color/holo_red_dark"   
  android:textSize="20sp" />


        <CheckBox           
    android:id="@+id/CB1"          
    android:layout_width="wrap_content"          
    android:layout_height="wrap_content"           
    android:checked="false"           
    android:text="Silk Saree"           
    android:textColor="#F00" />

        <CheckBox           
  android:id="@+id/CB2"           
  android:layout_width="wrap_content"           
  android:layout_height="wrap_content"          
   android:checked="false"          
    android:text="Synthetic Saree"           
    android:textColor="#F0F" />

        <CheckBox           
  android:id="@+id/CB3"           
  android:layout_width="wrap_content"           
  android:layout_height="wrap_content"           
  android:checked="false"           
  android:text="Cotton Saree"           
  android:textColor="#F00F" />
        <CheckBox           
  android:id="@+id/CB4"           
  android:layout_width="wrap_content"           
  android:layout_height="wrap_content"           
  android:checked="false"           
  android:text="Jute Saree"           
  android:textColor="#ff00" />
        <Button           
  android:layout_width="314dp"           
  android:layout_height="wrap_content"           
  android:text="PRESS IT"           
  android:id="@+id/btn"           
  android:background="#f8f40b"           
  android:textColor="#fd0707"/>
    </LinearLayout>
</ScrollView>
-----------------------------------------------------------------------------
D:\chandreadymadeshop\app\src\main\java\com\ldc\chandreadymadeshop\MainActivity.java
 
 
package com.ldc.chandreadymadeshop;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
    Button btn;
    CheckBox cb1, cb2, cb3,cb4;

    TextView v1;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        cb1=(CheckBox) findViewById(R.id.CB1);
        cb2=(CheckBox) findViewById(R.id.CB2);
        cb3=(CheckBox) findViewById(R.id.CB3);
        cb4=(CheckBox) findViewById(R.id.CB4);
        btn=(Button) findViewById(R.id.btn);
        v1=(TextView) findViewById(R.id.TV1);

        btn.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {
                String txt=" ";
                if(cb1.isChecked() == true )
                    txt=(String)cb1.getText();
                if(cb2.isChecked() == true )
                    txt=txt+", "+(String)cb2.getText();
                if(cb3.isChecked() == true )
                    txt=txt+"  , "+(String)cb3.getText();
                if(cb4.isChecked() == true )
                    txt=txt+"  , "+(String)cb4.getText();
                v1.setText("You have Selected "+txt);

                if(cb1.isChecked() == false && cb2.isChecked()==false && cb3.isChecked()==false && cb4.isChecked()==false)

                {
                    Toast.makeText(getBaseContext(),"OOPS! you haven`t selected anythng (: (: ",Toast.LENGTH_LONG).show();
                    v1.setText("You haven't Selected (: (; (: "+txt);
                }



            }
        });
    }
}
----------------------------------------------------------------------------------------
 

Monday, 26 August 2019

Android Programming - CheckBox

D:\chandreadymadeshop\app\src\main\res\layout\activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:background="@drawable/chandra">
 
 <LinearLayout         
android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:orientation="vertical">

        <TextView 
 android:id="@+id/TV1" 
 android:layout_width="wrap_content"             
android:layout_height="wrap_content" 
 android:text="Select Whatever you Want !!"             
android:textColor="@android:color/holo_red_dark" 
 android:textSize="40sp" />

        <CheckBox             
android:id="@+id/CB1" 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:checked="false" 
 android:text="Silk Saree" 
 android:textColor="@android:color/holo_orange_dark" />

        <CheckBox 
 android:id="@+id/CB2"             
android:layout_width="wrap_content"             
android:layout_height="wrap_content" 
 android:checked="false"             
android:text="Synthetic Saree" 
 android:textColor="@android:color/holo_green_dark" />

        <CheckBox 
 android:id="@+id/CB3" 
 android:layout_width="wrap_content" 
 
 android:layout_height="wrap_content"             
android:checked="false" 
 android:text="Cotton Saree" 
 android:textColor="@android:color/holo_blue_dark" />
 
 <CheckBox 
 android:id="@+id/CB4"             
android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:checked="false" 
 android:text="Jute Saree" 
 android:textColor="@android:color/holo_red_light" />
 
 <Button 
 android:layout_width="314dp"             
android:layout_height="wrap_content"             
android:text="PRESS IT"             
android:id="@+id/btn" 
 android:background="#f8f40b" 
 android:textColor="#fd0707"/>
    </LinearLayout>
</ScrollView>
-----------------------------------------------------------------------------------------
D:\chandreadymadeshop\app\src\main\java\com\ldc\chandreadymadeshop\MainActivity.java 

package com.ldc.chandreadymadeshop;



import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Toast;

public class MainActivity extends Activity {
    Button btn;
    CheckBox cb1, cb2, cb3,cb4;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        cb1=(CheckBox) findViewById(R.id.CB1);
        cb2=(CheckBox) findViewById(R.id.CB2);
        cb3=(CheckBox) findViewById(R.id.CB3);
        cb4=(CheckBox) findViewById(R.id.CB4);
        btn=(Button) findViewById(R.id.btn);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {
                if(cb1.isChecked() == true && cb2.isChecked()== false && cb3.isChecked()==false && cb4.isChecked()==false)
                    Toast.makeText(getBaseContext(),"Silk Saree", Toast.LENGTH_LONG).show();
                if(cb1.isChecked() == false && cb2.isChecked()==true && cb3.isChecked()==false && cb4.isChecked()==false)
                    Toast.makeText(getBaseContext(),"Synthetic  Saree",Toast.LENGTH_LONG).show();
                if(cb1.isChecked() == false && cb2.isChecked()==false && cb3.isChecked()==true && cb4.isChecked()==false)
                    Toast.makeText(getBaseContext(),"Cotton Saree",Toast.LENGTH_LONG).show();
                if(cb1.isChecked() == false && cb2.isChecked()==false && cb3.isChecked()== false && cb4.isChecked()==true)
                    Toast.makeText(getBaseContext(),"Jute Saree ",Toast.LENGTH_LONG).show();
                if(cb1.isChecked() == true && cb2.isChecked()==true && cb3.isChecked()== false && cb4.isChecked()==false)
                    Toast.makeText(getBaseContext(),"Silk Sree Cotton Saree  ",Toast.LENGTH_LONG).show();
                if(cb1.isChecked() == true && cb2.isChecked()==true && cb3.isChecked()== true && cb4.isChecked()==false)
                    Toast.makeText(getBaseContext(),"Silk Sree Cotton Saree and Synthetic Saree ",Toast.LENGTH_LONG).show();
                if(cb1.isChecked() == true && cb2.isChecked()==true && cb3.isChecked()== true && cb4.isChecked()==true)
                    Toast.makeText(getBaseContext(),"Silk Sree Cotton Saree , Synthetic Saree and Jute Saree",Toast.LENGTH_LONG).show();

                if(cb1.isChecked() == false && cb2.isChecked()==false && cb3.isChecked()==false && cb4.isChecked()==false)
                    Toast.makeText(getBaseContext(),"OOPS! you haven`t selected anythng (: (: ",Toast.LENGTH_LONG).show();


            }
        });
    }
}
------------------------------------------------------------------------------------

Thursday, 22 August 2019

Android Programming Image Button and Image View

Android Programming

 Image View and Image Button 

 D:\Treesdetailsusingimageviewandimagebutton\app\src\main\res\layout\activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:background="#FFF"    >

    //android:background="#FFFF00"

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

    <LinearLayout         
android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:orientation="horizontal">
 
 <ImageView 
 android:id="@+id/imgvw1"                 
android:layout_width="200dp" 
 android:layout_height="100dp" 
 android:scaleType="fitCenter"                 
android:tooltipText="Trees " 
 android:src="@drawable/tree"/>
 
 <Space 
 android:layout_width="10sp" 
 android:layout_height="wrap_content" />
 
 <TextView 
 android:id="@+id/tt1" 
 android:layout_width="wrap_content"             
android:layout_height="wrap_content" 
 android:text="Name"             
android:textAlignment="center" 
 android:textColor="@android:color/holo_red_dark"             
android:textSize="25sp"             
android:textStyle="italic" />
 
 <Space 
 android:layout_width="10sp" 
 android:layout_height="wrap_content" />
    </LinearLayout>
 
 <LinearLayout 
 android:layout_width="match_parent" 
 android:layout_height="match_parent"         
android:orientation="horizontal">

    <ImageButton                 
android:id="@+id/imgButton1"                 
android:layout_width="200dp"                 
android:layout_height="100dp" 
 android:scaleType="fitCenter" 
 android:src="@drawable/bananatree"/>
 
 <Space 
 android:layout_width="10sp" 
 android:layout_height="wrap_content" />
 
 <TextView 
 android:id="@+id/t1" 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content"
 android:textAlignment="center" 
 android:textColor="@android:color/holo_red_dark" 
 android:textSize="25sp" 
 android:textStyle="italic" />
 
 <Space 
 android:layout_width="10sp" 
 android:layout_height="wrap_content" />
 
 </LinearLayout>
    <LinearLayout 
 android:layout_width="match_parent" 
 android:layout_height="match_parent"         
android:orientation="horizontal">
 
 <ImageButton                 
android:id="@+id/imgButton2" 
 android:layout_width="200dp" 
 android:layout_height="100dp" 
 android:scaleType="fitCenter" 
 android:src="@drawable/pappayatree"/>
 
 <Space                 
android:layout_width="10sp" 
 android:layout_height="wrap_content" />
 
 <TextView             
android:id="@+id/t2"             
android:layout_width="wrap_content"             
android:layout_height="wrap_content"
android:textAlignment="center" 
 android:textColor="@android:color/holo_red_dark" 
 android:textSize="25sp"             
android:textStyle="italic" />
 
 <Space             
android:layout_width="10sp" 
 android:layout_height="wrap_content" />
 
 </LinearLayout>
 <LinearLayout         
android:layout_width="match_parent" 
 android:layout_height="match_parent"         
android:orientation="horizontal">
 
 <ImageButton 
 android:id="@+id/imgButton3" 
 android:layout_width="200dp"                 
android:layout_height="100dp"                 
android:scaleType="fitCenter"                 
android:src="@drawable/managotree"/>
 
 <Space 
 android:layout_width="10sp" 
 android:layout_height="wrap_content" />
 
 <TextView             
android:id="@+id/t3"             
android:layout_width="wrap_content" 
 android:layout_height="wrap_content"
 android:textAlignment="center" 
 android:textColor="@android:color/holo_red_dark" 
 android:textSize="25sp" 
 android:textStyle="italic" />
 <Space             
android:layout_width="10sp" 
 android:layout_height="wrap_content" />
 </LinearLayout>
 <LinearLayout 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:orientation="horizontal">
 
 <ImageButton 
 android:id="@+id/imgButton4"             
android:layout_width="200dp" 
 android:layout_height="100dp" 
 android:scaleType="fitCenter" 
 android:src="@drawable/close"/>
 
 <Space 
 android:layout_width="10sp"             
android:layout_height="wrap_content" />
 
 <TextView 
 android:id="@+id/t4" 
 android:layout_width="wrap_content"         
android:layout_height="wrap_content"         
android:text="Wind Up !"         
android:textAlignment="center" 
 android:textColor="@android:color/holo_red_dark" 
 android:textSize="25sp" 
 android:textStyle="italic" />
    </LinearLayout>
    </LinearLayout>
</ScrollView>
 
_____________________________________________________________________________
 
D:\Treesdetailsusingimageviewandimagebutton\app\src\main\res\layout\activity_main.xml
 
package com.ldc.treesdetailsusingimageviewandimagebutton;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.graphics.Color;


public class MainActivity extends Activity {
    EditText edittext1, edittext2;
    Button buttonSum,buttonSub,buttonMul;
    ImageButton imgb1,imgb2,imgb3,imgb4;
    TextView t1,t2,t3,t4;



    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imgb1=(ImageButton) findViewById(R.id.imgButton1);
        imgb2=(ImageButton) findViewById(R.id.imgButton2);
        imgb3=(ImageButton) findViewById(R.id.imgButton3);
        imgb4=(ImageButton) findViewById(R.id.imgButton4);
        final LinearLayout layout = (LinearLayout) findViewById(R.id.llayout1);

        t1 = (TextView) findViewById(R.id.t1);
        t2 = (TextView) findViewById(R.id.t2);
        t3 = (TextView) findViewById(R.id.t3);
       // t4 = (TextView) findViewById(R.id.t4);        imgb1.setBackgroundColor(Color.RED);
        imgb2.setBackgroundColor(Color.RED);
        imgb3.setBackgroundColor(Color.RED);
        imgb4.setBackgroundColor(Color.RED);

        imgb1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                t1.setText("BANANA TREE");
                layout.setBackgroundColor(Color.YELLOW);

            }});
        imgb2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                t2.setText("PAPPAYA TREE");
                layout.setBackgroundColor(Color.GREEN);

            }});
        imgb3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                t3.setText("MANGO TREE");
                layout.setBackgroundColor(Color.CYAN);

            }});


        imgb4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();

            }
        });

    }
}
______________________________________________________________