Skip to main content

How To Create App for Input a Value and Show it as a Toast message and in a Text box



How To Create App for Input a Value and Show it as a Toast message and in a Text box 

Step 1) Create New Android Project With Empty Activity.
Step 2)   Add a EditText, a Button and TextView In Design mode To activity_main.xml
or Hardcode it .

activity_main.xmlDesign mode



activity_main.xmlText mode





Step 3)  Program the App process in MainActivity.java.
·       Assign the Components.
·       Click Event.
·       Get Text , Set Text from EditText to TextView.
·       Toast Message.


         MainActivity.java





Code:

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.TextView;

import android.widget.Toast;


public class MainActivity extends AppCompatActivity {


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        Button btn1 = findViewById(R.id.button1);

        final EditText editText=findViewById(R.id.editText);

        final TextView textView=findViewById(R.id.textView);

        btn1.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {

                String inputtext=editText.getText().toString();



                textView.setText(inputtext);

                Toast.makeText(MainActivity.this,inputtext , Toast.LENGTH_SHORT).show();

            }

        });

    }

}


Step 4 ) Run The App on a Android Phone Or in a AVD emulator.

Comments

Popular posts from this blog

Best Torrent Sites

Torrent is one of the most recent technicals words because, Some of the world's most popular torrent websites are banned. However, as it is one of the most popular download methods in the world, torrent technology cannot be stopped. In our country, many people use torrents to download data such as films, games, and software. The torrent file-sharing method uses peer to peer (peer-to-peer) technology. This is the method of downloading files from one computer to another at the same time. It is on a computer that is downloading or downloading the torrent file. Here The Best Torrent Downloading Sites,   YTS.lt YTS   is Movie Torrent site, You Can download latest Movie's Torrent files, With Different Video Qualities, Also the have old movie Collections,    2. 1337X.to 1337x  Is the  Most Popular Torrent site nowadays, Because This Site has Lot of Things To download,  Such as  MOVIES TELEVISION(Library) GAMES MUS...

Simple Image Slider Using HTML & CSS

This Is the Simplest Image Slider I Have  Discovered, Because Its  Easy To Remember and it doesn't have any JavaScript Code, And remember one thing this is only designed for 4 Images and its animate using image Width. So you Have To use your Fist image as a 5th image Again to avoid transition Flash, Lets Begin. Preview HTML <html> <head> <title>Image Slider</title> </head> <body> <div id="slider"> <figure> <img src="img1.png"> <img src="img2.png"> <img src="img3.png"> <img src="img4.png"> <img src="img1.png"> </figure> </div> </body> </html> CSS #slider { overflow: hidden; } #slider figure { position: relative; width: 500%; margin: 0; left: 0; animation: 20s slider infinite; } #slider figure img { float: left; width: 20%; } @keyframes slider { 0% { left: 0; } 20% { left: 0; } 25% { left: -100%;...

Corona Virus COVID19 Outbreak Worldwide Stats MAP

Here the covid 19 Outbreak map You Can see Cases, Deaths and recovered Count in Worlwide.  Visit To Out Brack MAP https://infographics.channelnewsasia.com/covid-19/map.htm