ad728
Showing posts with label Android Application Development Project. Show all posts
Showing posts with label Android Application Development Project. Show all posts

Saturday, March 11, 2023

AIDE Tutorial - 20.4 WebView with SwipeRefreshLayout



Main.xml

<?xml version="1.0" encoding="utf-8"?>

 <RelativeLayout

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

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/container"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".Browser">


    <android.support.v4.widget.SwipeRefreshLayout

              android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:id="@+id/swipe">


        <android.support.v4.widget.NestedScrollView

            android:layout_width="match_parent"

            android:layout_height="match_parent">


            <WebView

                android:id="@+id/wv"

                android:layout_marginTop="10dp"

                   android:layout_width="match_parent"

                android:layout_height="match_parent">

            </WebView>

        </android.support.v4.widget.NestedScrollView>

    </android.support.v4.widget.SwipeRefreshLayout>

</RelativeLayout>


MainActivity.java

package com.mycompany.myapp2;

import android.app.*;
import android.os.*;
import android.webkit.*;
import android.widget.*;
import android.support.v4.widget.*;
import android.view.*;
import android.content.*;

public class MainActivity extends Activity
{WebView wv;
 
    SwipeRefreshLayout swipe;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
wv=(WebView)findViewById(R.id.wv);
        swipe = (SwipeRefreshLayout)findViewById(R.id.swipe);

     
   
        wv.loadUrl("https://shyamkumarkc20.com.np");
        WebSettings webSettings = wv.getSettings();
        webSettings.setJavaScriptEnabled(true);
        wv.getSettings().setAppCacheEnabled(true);
swipe.setRefreshing(true);
        wv.setWebViewClient(new WebViewClient(){
public void onPageFinished (WebView view, String url){
swipe.setRefreshing(false);
}
});
swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
wv.reload();
}





});
}
@Override
    // Detect when the back button is pressed
    public void onBackPressed() {
        if(wv.canGoBack()) {
            wv.goBack();
        } else {


AlertDialog.Builder builder=new AlertDialog.Builder(MainActivity.this);
builder.setMessage("Are you sure you want to exit?");
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which)
{
MainActivity.this.finish();
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.cancel();
}
});
AlertDialog alert =builder.create();
alert.show();
}
}


}


Manifest
<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Share:

Saturday, February 20, 2021

AIDE Tutorial - 32 VideoView


Main xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <VideoView
        android:id="@+id/videoView"
        android:layout_width="match_parent"
      android:layout_height="match_parent"
       />
</LinearLayout>
Java
package com.mycompany.myapp5;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.net.*;
import org.apache.http.client.protocol.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
   

VideoView video=(VideoView)findViewById(R.id.videoView);
video.setVideoURI(Uri.parse("android.resource://"+ getPackageName() + "/" + R.raw.customlayout));
video.setMediaController(new MediaController(this));
video.requestFocus();



}
}
Share:

Saturday, April 25, 2020

AIDE TUTORIAL - 60.1 Battery Indicator with Progress Bar



Main.xml
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical">

<TextView android:id="@+id/mainTextView"android:textSize="40dp"android:layout_width="wrap_content"android:layout_height="wrap_content"/>

<ProgressBar android:max="100"android:id="@+id/mainProgressBar"style="?android:attr/progressBarStyleHorizontal"android:layout_height="wrap_content"android:layout_width="wrap_content"android:minHeight="50dp"android:minWidth="150dp"/>
</LinearLayout>

MainActivity.java
package com.kcgroup.bipb; import android.app.*; import android.os.*; import android.content.*; import android.widget.*; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); registerReceiver(bp, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); } private BroadcastReceiver bp=new BroadcastReceiver(){ @Override public void onReceive(Context p1, Intent p2) { int level=p2.getIntExtra("level",0); TextView tv=(TextView)findViewById(R.id.mainTextView); ProgressBar pb=(ProgressBar)findViewById(R.id.mainProgressBar); tv.setText("Battery Level:"+Integer.toString(level)+"%"); pb.setProgress(level); // TODO: Implement this method } }; }
Share:

Sunday, June 10, 2018

AIDE Tutorial - 58.1 Call App with EditText

AIDE Tutorial - 58.1 Call App with EditText
Watch the video below
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <EditText
android:id="@+id/mainEditText"
android:inputType="number"
android:hint="Enter phone number here"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:onClick="call"
android:text="Call"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java
package com.kcgroup.callapp;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
import android.content.*;
import android.net.*;
public class MainActivity extends Activity
{EditText et;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
et=(EditText)findViewById(R.id.mainEditText);
    }
public void call(View v){
String st=et.getText().toString();
Intent in=new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+st));
startActivity(in);
}
}
Androidmanifest.xml
<uses-permission android:name="android.permission.CALL_PHONE"/>
I
Share:

AIDE Tutorial - 58 Call Action Button

AIDE Tutorial - 58 Call Action Button

Watch the video below
Main xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:onClick="call"
        android:text="Call"        android:layout_width="wrap_content"        android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java
package com.kcgroup.callaction;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
import android.net.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
public void call(View v){
Intent in=new Intent(Intent.ACTION_CALL,Uri.parse("tel:0123456789"));
startActivity(in);
}
}
Manifest.xml
<uses-permission android:name="android.permission.CALL_PHONE"/>
  
Share:

Tuesday, May 22, 2018

AIDE Tutorial - 57 Open another Activity

AIDE Tutorial - 57 Open another Activity

Watch the video below
Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:id="@+id/mainButton"
        android:text="Open another Activity"
        android:layout_width="wrap_content"        android:layout_height="wrap_content" />
</LinearLayout>
Second.xml
<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:text="This is the second activity"
android:layout_width="wrap_content"android:layout_height="wrap_content"/>
</LinearLayout>
MainActivity.java
package com.kcgroup.anotheractivity;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{    @Override
    protected void onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
Button btn=(Button)findViewById(R.id.mainButton);
btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View p1)
{Intent in=new Intent(MainActivity.this, SecondActivity.class);
startActivity(in);
// TODO: Implement this method
}});    }}
SecondActivity.java
package com.kcgroup.anotheractivity;
import android.app.*;
import android.os.*;
public class SecondActivity extends Activity
{    @Override
    protected void onCreate(Bundle savedInstanceState)
    {        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);
    }}
Share:

Tuesday, May 15, 2018

AIDE Tutorial - 55 BMI Calculator

AIDE Tutorial - 55 BMI Calculator
Watch the video below
Main xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_marginBottom="20dp"
android:textSize="25dp"
android:text="BMI Calculator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<EditText
android:inputType="number|numberDecimal"
android:layout_marginBottom="20dp"
android:maxLength="3"
android:id="@+id/edittext1"
android:hint="Enter your Weight  here [Kg]"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:inputType="number|numberDecimal"
android:layout_marginBottom="20dp"
android:maxLength="3"
android:id="@+id/edittext2"
android:hint="Enter your Height here [M]"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:layout_marginBottom="20dp"
android:id="@+id/calculate"
android:text="Calculate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginBottom="20dp"
android:id="@+id/textview"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
MainActivity.java
package com.kcgroup.bmicalculator;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
public class MainActivity extends Activity
{private EditText et1,et2;
private Button btn;
private TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

et1=(EditText)findViewById(R.id.edittext1); et2=(EditText)findViewById(R.id.edittext2);
btn=(Button)findViewById(R.id.calculate); tv=(TextView)findViewById(R.id.textview);

btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View p1)
{
double a=Double.parseDouble(et1.getText().toString());
double b=Double.parseDouble(et2.getText().toString());
double ans= a/(b*b); tv.setText(String.valueOf(ans)); } });

}}
Share:

Monday, May 14, 2018

AIDE Tutorial - 56 Table Layout

AIDE Tutorial - 56 Table Layout
Watch the video below
Main xml
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<TableRow>
    <Button
android:background="@drawable/background_et"
        android:text="T11"
        android:layout_width="wrap_content"        android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<Button
android:background="@drawable/background_et"
android:text="T21"
android:layout_width="wrap_content"android:layout_height="wrap_content" />
<Button
android:background="@drawable/background_et"
android:text="T22"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:background="@drawable/background_et"
android:text="T31"/>
<Button
android:background="@drawable/background_et"
android:text="T32" />
<Button
android:background="@drawable/background_et"
android:text="T33"/>
</TableRow>
</TableLayout>
Share:

Monday, April 30, 2018

AIDE Tutorial - 54 Simple Calculator

AIDE Tutorial - 54 Simple Calculator
Watch the video below Main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"  >
<EditText
android:id="@+id/edittext1"
android:inputType="number|numberDecimal"
android:layout_width="match_parent"        android:layout_height="wrap_content" />
<EditText
android:layout_below="@+id/edittext1"
android:id="@+id/edittext2"
android:inputType="number|numberDecimal"
android:layout_width="match_parent"        android:layout_height="wrap_content" />
<Button
android:layout_below="@+id/edittext2"
android:id="@+id/add"
android:text="Add"
android:layout_width="wrap_content"        android:layout_height="wrap_content" />
<Button
android:layout_below="@+id/add"
android:id="@+id/subtract"
android:text="Subtract"
android:layout_width="wrap_content"        android:layout_height="wrap_content" />
<Button
android:layout_below="@+id/subtract"
android:id="@+id/multiply"
android:text="Multiply"
android:layout_width="wrap_content"      android:layout_height="wrap_content" />
<Button
android:layout_below="@+id/multiply"
android:id="@+id/divide"
android:text="Divide"
android:layout_width="wrap_content"        android:layout_height="wrap_content" />
    <TextView
android:id="@+id/mainTextView"
android:layout_below="@+id/divide"
        android:text=""
        android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</RelativeLayout>

Main.xml
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"  >
<EditText
android:id="@+id/edittext1"
android:inputType="number|numberDecimal"
android:layout_width="match_parent"        
android:layout_height="wrap_content" />
<EditText
android:layout_below="@+id/edittext1"
android:id="@+id/edittext2"
android:inputType="number|numberDecimal"
android:layout_width="match_parent"        
android:layout_height="wrap_content" />
<Button
android:layout_below="@+id/edittext2"
android:id="@+id/add"
android:text="Add"
android:layout_width="wrap_content"        
android:layout_height="wrap_content" />
<Button
android:layout_below="@+id/add"
android:id="@+id/subtract"
android:text="Subtract"
android:layout_width="wrap_content"        
android:layout_height="wrap_content" />
<Button
android:layout_below="@+id/subtract"
android:id="@+id/multiply"
android:text="Multiply"
android:layout_width="wrap_content"      
android:layout_height="wrap_content" />
<Button
android:layout_below="@+id/multiply"
android:id="@+id/divide"
android:text="Divide"
android:layout_width="wrap_content"        
android:layout_height="wrap_content" />
    <TextView
android:id="@+id/mainTextView"
android:layout_below="@+id/divide"
        android:text=""
        android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</RelativeLayout>
MainActivity.java
package com.kcgroup.simplecalculator;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
public class MainActivity extends Activity
{ private Button btnadd, btnsub, btnmul, btndiv;
private EditText et1,et2;
private TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
btnadd=(Button)findViewById(R.id.add);
btnsub=(Button)findViewById(R.id.subtract);
btnmul=(Button)findViewById(R.id.multiply);
btndiv=(Button)findViewById(R.id.divide);
et1=(EditText)findViewById(R.id.edittext1);
et2=(EditText)findViewById(R.id.edittext2);
tv=(TextView)findViewById(R.id.mainTextView);

btnadd.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View p1)
{
double a=Double.parseDouble(et1.getText().toString());
double b=Double.parseDouble(et2.getText().toString());
double result=a+b;
tv.setText(String.valueOf(result));

// TODO: Implement this method
} });

btnsub.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View p1)
{
double a=Double.parseDouble(et1.getText().toString());
double b=Double.parseDouble(et2.getText().toString());
double result=a-b;
tv.setText(String.valueOf(result));
// TODO: Implement this method
} });

btnmul.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View p1)
{
double a=Double.parseDouble(et1.getText().toString());
double b=Double.parseDouble(et2.getText().toString());
double result=a*b;
tv.setText(String.valueOf(result));
// TODO: Implement this method
} });

btndiv.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View p1)
{
double a=Double.parseDouble(et1.getText().toString());
double b=Double.parseDouble(et2.getText().toString());
double result=a/b;
tv.setText(String.valueOf(result)); } });
  }}
Share:

Saturday, February 17, 2018

AIDE Tutorial - 6.2 Round Corner Button

AIDE Tutorial - 6.2 Round Corner Button

Watch the video below

Main xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   android:gravity="center" >
  
  <Button
android:background="@drawable/round_corner_button"
        android:text="Round Corner Button"
        android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"/>
</LinearLayout>


round_corner_button xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#EFE1E0"/>
<stroke android:color="#2CE20E"
android:width="3dp"/>
<corners android:radius="20dp"/>
</shape> </item></selector>

Related Articles:

  1. AIDE Tutorial - 6 Button
  2. AIDE Tutorial - 6.1 Round Button
  3. AIDE Tutorial- 6.2 Round Corner Button
Share:

Saturday, January 20, 2018

AIDE Tutorial - 53 Change WiFi State

AIDE Tutorial - 53 Change WiFi State


Watch the Video Below:

Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   android:orientation="vertical" >
    <Button
android:id="@+id/mainButtonOn"
        android:text="Turn On Wifi"        android:layout_width="wrap_content"        android:layout_height="wrap_content" />
<Button
android:id="@+id/mainButtonOff"
        android:text="Turn Off Wifi"       android:layout_width="wrap_content"        android:layout_height="wrap_content" />
</LinearLayout>

MainActivity.java
package com.kcgroup.CWS;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.View.*;
import android.view.*;
import android.net.wifi.*;
import android.content.*;
public class MainActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
Button btnOn=(Button)findViewById(R.id.mainButtonOn);
btnOn.setOnClickListener(new View.OnClickListener(){

@Override
public void onClick(View p1)
{WifiManager wifi=(WifiManager)getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(true);Toast.makeText(getApplicationContext(),"WiFi is turned ON",Toast.LENGTH_SHORT).show();}});
Button btnOff=(Button)findViewById(R.id.mainButtonOff);
btnOff.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View p1)
{WifiManager wifi=(WifiManager)getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(false);Toast.makeText(getApplicationContext(),"WiFi is turned OFF",Toast.LENGTH_SHORT).show();}});    }}
Manifest.xml
uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
  
1.Aide Tutorial - 20 Webview
2. Aide Tutorial - 20.1 Webview with ProgressBar
3. Aide tutorial - 20.2 webview with back button
4. Aide tutorial - 20.3 webview with exit button
Share:

Thursday, January 18, 2018

AIDE Tutorial - 52 Custom WebView

AIDE Tutorial - 52 Custom WebView


Watch the Video Below:

MainActivity.java
package com.kcgroup.CWeb;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.View.*;
import android.view.*;
import android.webkit.*;
public class MainActivity extends Activity
{Button btn; EditText et;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {      super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
btn=(Button)findViewById(R.id.mainButton);
et=(EditText)findViewById(R.id.mainEditText);
btn.setOnClickListener( new View.OnClickListener()
{@Override
public void onClick(View p1)
{String weburl=et.getText().toString();
WebView web=(WebView)findViewById(R.id.mainWebView);
web.setWebViewClient(new WebViewClient());
web.loadUrl(weburl);
// TODO: Implement this method
}});   }}

Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <EditText
android:id="@+id/mainEditText"
        android:hint="Type your own url Start with http:// or https://"
        android:layout_width="wrap_content"       android:layout_height="wrap_content" />
<Button
android:text="Go"
android:id="@+id/mainButton"android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<WebView
android:id="@+id/mainWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
Manifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
Share:

Sunday, January 14, 2018

AIDE Tutorial - 7.1 Customize Toast

AIDE Tutorial - 7.1 Customize Toast

Watch the Video Below:
MainActivity.java
package com.kcgroup.CT;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.View.*;
import android.view.*;

public class MainActivity extends Activity 
{ EditText et; Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {     super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
et=(EditText)findViewById(R.id.mainEditText);
btn=(Button)findViewById(R.id.mainButton);
btn.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View p1)
{
String text=et.getText().toString();
Toast.makeText(MainActivity.this,text,
Toast.LENGTH_SHORT).show();
// TODO: Implement this method
} });  }}

Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   android:orientation="vertical" >

    <EditText
android:id="@+id/mainEditText"
        android:hint="Enter your own toast message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
<Button
android:text="Create Toast"
android:id="@+id/mainButton"
android:layout_width="wrap_content"
        android:layout_height="wrap_content" /> </LinearLayout>
Share:

Saturday, January 13, 2018

AIDE Tutorial - 51 Volume Calculator


Watch the Video Below:

MainActivity.java
package com.kcgroup.vc;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.View.*;
import android.view.*;

public class MainActivity extends Activity
{ TextView Result;
EditText HeightET,BreadthET,LengthET;
    @Override
    protected void onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
Button btncal=(Button)findViewById(R.id.maincalbutton);
HeightET=(EditText)findViewById(R.id.mainEditTextheight);
BreadthET=(EditText)findViewById(R.id.mainEditTextbreadth);
LengthET =(EditText)findViewById(R.id.mainEditTextlength);
Result=(TextView)findViewById(R.id.mainTextViewResult);
btncal.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v)
{float heigth,length,breadth,volume;heigth=Float.parseFloat(HeightET.getText().toString());length=Float.parseFloat(LengthET.getText().toString());breadth=Float.parseFloat(BreadthET.getText().toString());
volume=length*breadth*heigth;
Result.setText("Result : "+volume);
// TODO: Implement this method
}});    }}

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:text="Enter Height"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<EditText
android:inputType="number|numberDecimal"
android:id="@+id/mainEditTextheight"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="Enter Breadth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<EditText
android:inputType="number|numberDecimal"
android:id="@+id/mainEditTextbreadth"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="Enter Length"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<EditText
android:inputType="number|numberDecimal"
android:id="@+id/mainEditTextlength"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button
android:text="Calculate"
android:id="@+id/maincalbutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/mainTextViewResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>

Share:

Friday, December 29, 2017

AIDE Tutorial - 46 Blink Animation

AIDE Tutorial - 46 Blink Animation
Java
package com.kcgroup.animblink;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.view.animation.*;
public class MainActivity extends Activity
{   @Override
    protected void onCreate(Bundle savedInstanceState)
    {super.onCreate(savedInstanceState);
        setContentView(R.layout.main);    }
public void blink(View v){
ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.blink);
image.startAnimation(an);}}
Main xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <ImageView
android:layout_weight="4"
        android:src="@drawable/ic_launcher"
android:id="@+id/mainImageView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
<Button
android:text="Blink"
android:onClick="blink"
android:layout_width="wrap_content"        android:layout_height="wrap_content" />
</LinearLayout>
Blink.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
>
<alpha android:fromAlpha="0"
android:toAlpha="1"
android:duration="1000"
android:repeatMode="reverse"
android:repeatCount="2"/>
</set>
Other Related Articles:
  1. AIDE Tutorial - 41 Animation Fade In & Fade Out
  2. AIDE Tutorial - 42 Animation Zoom In & Zoom Out
  3. AIDE Tutorial - 43 Animation Bounce Top Bottom Left Right
  4. AIDE Tutorial - 44 Rotate Animation
  5. AIDE Tutorial - 45 Slide Animation
  6. AIDE Tutorial - 46 Blink Animation
Share:

AIDE Tutorial - 43 Animation Bounce Top Bottom Left Right

AIDE Tutorial - 43 Animation Bounce Top Bottom Left Right

Watch the video below

Main Activity.java
package com.kcgroup.animbounce;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.view.animation.*;
public class MainActivity extends Activity
{    @Override
    protected void onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);    }
public void top(View v){
ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.bounce_top);
image.startAnimation(an);}
public void bottom(View v){ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.bounce_bottom);
image.startAnimation(an);}
public void right(View v){
ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.bounce_right);
image.startAnimation(an);}
public void left(View v){ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.bounce_left);image.startAnimation(an);}}

Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <ImageView
android:layout_weight="4"
android:id="@+id/mainImageView"
        android:src="@drawable/ic_launcher"
        android:layout_width="match_parent"        android:layout_height="wrap_content" />
<Button
android:text="Top"
android:onClick="top"
android:layout_width="match_parent"        android:layout_height="wrap_content" />
<Button
android:text="Bottom"
android:onClick="bottom"
android:layout_width="match_parent"        android:layout_height="wrap_content" />
<Button
android:text="Right"
android:onClick="right"
android:layout_width="match_parent"        android:layout_height="wrap_content" />
<Button
android:text="Left"
android:onClick="left"
android:layout_width="match_parent"        android:layout_height="wrap_content" />
</LinearLayout>
Create a new folder anim add four xml
Bounce_Bottom.xml
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:interpolator="@android:anim/bounce_interpolator">
<scale
android:duration="1000"
android:fromXScale="1"
android:fromYScale="0"
android:toXScale="1"
android:toYScale="1"></scale></set>
Bounce_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:interpolator="@android:anim/bounce_interpolator">
<scale
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:toXScale="0"
android:toYScale="1"></scale></set>
Bounce_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:interpolator="@android:anim/bounce_interpolator">
<scale
android:duration="1000"
android:fromXScale="0"
android:fromYScale="1"
android:toXScale="1"
android:toYScale="1"></scale></set>

Bounce_Top.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
   android:fillAfter="true"
   android:interpolator="@android:anim/bounce_interpolator">
   <scale
   android:duration="1000"
   android:fromXScale="1"
   android:fromYScale="1"
   android:toXScale="1"
   android:toYScale="0"></scale></set>

Share:

Saturday, December 16, 2017

AIDE Tutorial - 50 Rating Bar

AIDE Tutorial - 50 Rating Bar
Watch the Video Below


Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   android:orientation="vertical" >
    <TextView
        android:text="Rate Our App"
        android:layout_width="wrap_content"       android:layout_height="wrap_content" />
<RatingBar
android:text="Rate: "
android:id="@+id/mainRatingBar"
android:layout_width="wrap_content"        android:layout_height="wrap_content" />
<TextView
android:textSize="20sp"
android:id="@+id/mainTextView"
android:text="Rating :"
android:layout_width="wrap_content"       android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java
package com.kcgroup.ratingbar;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.widget.RatingBar.*;
public class MainActivity extends Activity
{    @Override
    protected void onCreate(Bundle savedInstanceState)   {        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
final TextView Result=(TextView)findViewById(R.id.mainTextView);
RatingBar RB=(RatingBar)findViewById(R.id.mainRatingBar);
RB.setOnRatingBarChangeListener(new OnRatingBarChangeListener(){
@Override
public void onRatingChanged(RatingBar arg0,float rating,boolean arg2){Result.setText("Rating :"+String.valueOf(rating));}});    }}
Share:

Thursday, December 14, 2017

AIDE Tutorial - 44 Rotate Animation

AIDE Tutorial - 44 Rotate Animation

Watch the Video Below

MainActivity.Java
package com.kcgroup.animrotate;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.view.animation.*;
public class MainActivity extends Activity
{ @Override

    protected void onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);    }
public void cw(View v){ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.rotate_clockwise);
image.startAnimation(an);}
public void ccw(View v){ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.rotate_countercw);image.startAnimation(an);}}
Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   android:orientation="vertical" >
    <ImageView
android:layout_weight="4"
android:id="@+id/mainImageView"
        android:src="@drawable/ic_launcher"
        android:layout_width="match_parent"      android:layout_height="wrap_content" />
<Button
android:onClick="cw"
android:text="Clock Wise"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:onClick="ccw"
android:text="Counter Clock wise"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Rotate_clockwise.xml
<?xml version="1.0" encoding="utf-8"?>
<setxmlns:android="http://schemas.android.com/apk/res/android"
>
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:repeatCount="2"
android:interpolator="@android:anim/cycle_interpolator"/></set>
Rotate_CounterClockWise.xml
<?xml version="1.0" encoding="utf-8"?>
<setxmlns:android="http://schemas.android.com/apk/res/android"
>
<rotate
android:fromDegrees="360"
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:repeatCount="2"
android:interpolator="@android:anim/cycle_interpolator"/></set>
Share:

Wednesday, December 13, 2017

AIDE Tutorial - 45 Slide Animation

AIDE Tutorial - 45 Slide Animation

Watch the Video Below
MainActivity.java
package com.kcgroup.animslide;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.animation.*;
import android.view.*;
public class MainActivity extends Activity
{    @Override
    protected void onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);    }
public void top(View v){
ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.silde_top);
image.startAnimation(an);}
public void bottom(View v){ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.silde_bottom);
image.startAnimation(an);}
public void right(View v){
ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slide_right);
image.startAnimation(an);}
public void left(View v){ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slide_left);
image.startAnimation(an);}}


Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <ImageView
android:layout_weight="4"
android:id="@+id/mainImageView"
        android:src="@drawable/ic_launcher"
        android:layout_width="match_parent"        android:layout_height="wrap_content" />
<Button
android:onClick="top"
android:text="Top"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:onClick="bottom"
android:text="Bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:onClick="right"
android:text="Right"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:onClick="left"
android:text="Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /></LinearLayout>


Slide_bottom.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:duration="2000"
android:fromXScale="1"
android:fromYScale="0"
android:toXScale="1"
android:toYScale="1"
android:interpolator="@android:anim/linear_interpolator"/>
</set>

Slide_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:duration="2000"
android:fromXScale="1"
android:fromYScale="1"
android:toXScale="0"
android:toYScale="1"
android:interpolator="@android:anim/linear_interpolator"/>
</set>

Slide_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:duration="2000"
android:fromXScale="0"
android:fromYScale="1"
android:toXScale="1"
android:toYScale="1"
android:interpolator="@android:anim/linear_interpolator"/>
</set>

Slide_top.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:duration="2000"
android:fromXScale="1"
android:fromYScale="1"
android:toXScale="1"
android:toYScale="0"
android:interpolator="@android:anim/linear_interpolator"/>
</set>
Share:

Sunday, December 10, 2017

AIDE Tutorial - 49.1 Context Menu on ListView

AIDE Tutorial - 49.1 Context Menu on ListView

Watch the Video Below



Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <ListView
android:id="@+id/mainTextView"
android:layout_width="wrap_content"      android:layout_height="wrap_content" />
</LinearLayout>
Main Activity.java
package com.kcgroup.CM;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
import android.view.ContextMenu.*;
public class MainActivity extends Activity
{ListView list;
    @Override
    protected void onCreate(Bundle savedInstanceState)   {       super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
list=(ListView)findViewById(R.id.mainTextView);

String[] name={"A","B","C","D"};
ArrayAdapter adapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1,name);
list.setAdapter(adapter);
registerForContextMenu(list);    }
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)
{ // TODO: Implement this method
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Select Action");
menu.add(0,v.getId(),0,"Call");
menu.add(0,v.getId(),0,"SMS");
menu.add(0,v.getId(),0,"VideoCall"); }
@Override
public boolean onContextItemSelected(MenuItem item)
{ if(item.getTitle()=="Call"){
Toast.makeText(this,"Call is Clicked",Toast.LENGTH_SHORT).show();
} else
if(item.getTitle()=="SMS"){
Toast.makeText(this,"SMS is Clicked",Toast.LENGTH_SHORT).show();
} else
if(item.getTitle()=="VideoCall"){ Toast.makeText(this,"VideoCall is Clicked",Toast.LENGTH_SHORT).show(); }
// TODO: Implement this method
return true; }}
Share:

Total Pageviews

Sponsor

Sponsor

ad300