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

How To Create First Hello World Android Application

Create First Hello World Android  Application Step 1)  Click Create New Project   on Android Studio Landing Page or   File > New> New   Project On IDE. Step 2)     A new Wizard Will Appear in That Wizard Give Name To Your Application (Name Must Be Start With Capital Letter)   And you can Choose Project Location. After filling that Click NEXT . Step 3)   In Next Wizard You Have to Select Minimum SDK Version For Your Application Step 4)   Next Wizard Will be   for select First Activity Appearance    (Select It as Empty Activity) Step 5)   Next Wizard For Name The First Activity . After that Click Finish. ·        After Click Finish Default Hello World Project Will Build Automatically . ·        This Is the Layout Code of Default Hello Wor...

What Is Grammarly

 What's Grammarly These days Grammarly is a great tool that allows writers, Low  English Knowlege Peoples, and different professionals to proofread and edit their paperwork for grammar and spelling. Grammarly checks for greater than 250 sorts of spelling, grammar and punctuation errors, and enhances vocabulary utilization. Each an internet model and one which integrates with MS Phrase can be found.