Добавить новость
News in English


Новости сегодня

Новости от TheMoneytizer

SLIP 18 Q1-Q2

Q1---------------------------------------------------------------------------------------------------

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"
    android:background="#000000"
    tools:context=".MainActivity"
    android:padding="10dp">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorAccent">

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="Hello World!"
            android:background="#A00000FF"
            android:gravity="center_vertical|center_horizontal"
            android:textColor="#ffffff"
            android:textSize="40sp" />
    </LinearLayout>

</RelativeLayout>





MainActivity.java



package com.example.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

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






q********************************************************************************

Q2-------------------------------------------------------------------------------------



activity_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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.sakshi.bankaccount.MainActivity">


    <EditText
        android:id="@+id/t1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginStart="11dp"
        android:layout_marginLeft="11dp"
        android:layout_marginTop="17dp"
        android:background="#fb1177"
        android:ems="10"
        android:hint="Name"
        android:inputType="textPersonName" />

    <EditText
        android:id="@+id/t2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/t1"
        android:layout_alignStart="@+id/t1"
        android:layout_alignLeft="@+id/t1"
        android:layout_marginTop="15dp"
        android:background="#fb1177"
        android:ems="10"
        android:hint="Account Number"
        android:inputType="numberSigned" />

    <EditText
        android:id="@+id/t3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/t2"
        android:layout_alignStart="@+id/t2"
        android:layout_alignLeft="@+id/t2"
        android:layout_marginTop="15dp"
        android:background="#fb1177"
        android:ems="10"
        android:hint="Balance"
        android:inputType="numberSigned" />

    <Switch
        android:id="@+id/s1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/t1"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_marginEnd="32dp"
        android:layout_marginRight="32dp"
        android:text="Switch" />

    <ToggleButton
        android:id="@+id/tb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/t3"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="24dp"
        android:background="#11ff00"
        android:text="ToggleButton"
        android:textOff="Withraw"
        android:textOn="Deposit" />

    <EditText
        android:id="@+id/t4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/tb"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="94dp"
        android:background="#fb1177"
        android:ems="10"
        android:hint="Enter The Amount"
        android:inputType="numberSigned" />

    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/t4"
        android:layout_alignStart="@+id/b"
        android:layout_alignLeft="@+id/b"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_marginTop="42dp"
        android:background="#ff00ff"
        android:text="Total Amount"
        android:textSize="18sp" />

    <Button
        android:id="@+id/b"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/tb"
        android:layout_alignEnd="@+id/tb"
        android:layout_alignRight="@+id/tb"
        android:layout_marginTop="22dp"
        android:background="#ff0"
        android:onClick="DoHandle"
        android:text="Do" />


</RelativeLayout>


MainActivity.java



package com.example.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.ToggleButton;

public class MainActivity extends AppCompatActivity {
    EditText t1, t2, t3, t4;
    TextView tv;
    Switch s1;
    ToggleButton tb;
    Button b;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        t1 = findViewById(R.id.t1);
        t2 = findViewById(R.id.t2);
        t3 = findViewById(R.id.t3);
        t4 = findViewById(R.id.t4);
        tv = findViewById(R.id.tv);
        s1 = findViewById(R.id.s1);
        tb = findViewById(R.id.tb);
        b = findViewById(R.id.b);
    }

    public void DoHandle(View v) {
        try {
            if (!s1.isChecked()) {
                setTitle("Bank Closed");
            }
            int acc = Integer.parseInt("" + t2.getText());
            Integer bal = Integer.parseInt("" + t3.getText());
            Integer amm = Integer.parseInt("" + t4.getText());
            if (s1.isChecked() && tb.isChecked()) {
                setTitle("Amount Deposit");
                bal = bal+amm-5;
                tv.setText("Updated Balance=" + bal);
            } else if (s1.isChecked() && !tb.isChecked() && bal>amm+5 ) {
                setTitle("Amount Withdraw");
                bal = bal-amm-5;
                tv.setText("Updated Balance=" + bal);
            }
            else
            if(s1.isChecked() && !tb.isChecked() && bal<=amm+5){
                setTitle("Amount Withdraw");
                tv.setText("Insufficient Balance");
            }
        } catch (Exception ex) {
            System.out.println(ex);
            tv.setText(ex.getMessage());

        }
    }

}

Читайте на сайте


Smi24.net — ежеминутные новости с ежедневным архивом. Только у нас — все главные новости дня без политической цензуры. Абсолютно все точки зрения, трезвая аналитика, цивилизованные споры и обсуждения без взаимных обвинений и оскорблений. Помните, что не у всех точка зрения совпадает с Вашей. Уважайте мнение других, даже если Вы отстаиваете свой взгляд и свою позицию. Мы не навязываем Вам своё видение, мы даём Вам срез событий дня без цензуры и без купюр. Новости, какие они есть —онлайн с поминутным архивом по всем городам и регионам России, Украины, Белоруссии и Абхазии. Smi24.net — живые новости в живом эфире! Быстрый поиск от Smi24.net — это не только возможность первым узнать, но и преимущество сообщить срочные новости мгновенно на любом языке мира и быть услышанным тут же. В любую минуту Вы можете добавить свою новость - здесь.




Новости от наших партнёров в Вашем городе

Ria.city
Музыкальные новости
Новости России
Экология в России и мире
Спорт в России и мире
Moscow.media










Топ новостей на этот час

Rss.plus