Blog purpose for android basic example for android app developer. any query please my contact

Tuesday, 2 February 2021

android studio popup window with input text

 android studio popup window with input text

In this Article Today Learn android studio popup window with input text. follow the full source code android studio popup window with input text.


1.MainActivity.java:

package com.akash.popupwindow;

import androidx.appcompat.app.AppCompatActivity;

import android.app.AlertDialog;

import android.content.DialogInterface;

import android.os.Bundle;

import android.text.InputType;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;


public class MainActivity extends AppCompatActivity {

    private String m_Text = "";

    Button btnview;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        btnview=(Button)findViewById(R.id.btnview);

        btnview.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {

                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);

                builder.setTitle("Title");


// Set up the input

                final EditText input = new EditText(MainActivity.this);

// Specify the type of input expected; this, for example, sets the input as a password, and will mask the text

                input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

                builder.setView(input);


// Set up the buttons

                builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

                    @Override

                    public void onClick(DialogInterface dialog, int which) {

                        m_Text = input.getText().toString();

                    }

                });

                builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

                    @Override

                    public void onClick(DialogInterface dialog, int which) {

                        dialog.cancel();

                    }

                });


                builder.show();

            }

        });

    }

}



2.activity_main.xml:

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

<androidx.constraintlayout.widget.ConstraintLayout 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=".MainActivity">


    <Button

        android:id="@+id/btnview"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="Click open popup"

        app:layout_constraintBottom_toBottomOf="parent"

        app:layout_constraintLeft_toLeftOf="parent"

        app:layout_constraintRight_toRightOf="parent"

        app:layout_constraintTop_toTopOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>


3.AndroidManifest.xml:

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

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

    package="com.akash.popupwindow">


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


4.colors.xml:

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

<resources>

    <color name="colorPrimary">#6200EE</color>

    <color name="colorPrimaryDark">#3700B3</color>

    <color name="colorAccent">#03DAC5</color>

</resources>


5.strings.xml:

<resources>

    <string name="app_name">Popup window</string>

</resources>


6.styles.xml:

<resources>

    <!-- Base application theme. -->

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

        <!-- Customize your theme here. -->

        <item name="colorPrimary">@color/colorPrimary</item>

        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>

        <item name="colorAccent">@color/colorAccent</item>

    </style>


</resources>


7.Output:

android studio popup window with input text













android studio popup window with input text


23 comments:

  1. It is a great post really enjoy reading such type of articles. I will also recommend you to visit Alightmotionguru.com, a blog related to AM app a great app having multiple motion effects
    . You can easily download such effects.

    ReplyDelete
  2. Interesting post with the points that I was missing. If you are interested in making cool videos get Alight motion for ios

    ReplyDelete
  3. I love reading things like this, so thank you for writing it. A excellent video editor with a variety of motion effects is the Alight Motion video editor, and I highly recommend it. Such effects are readily available for download at https://alightmotionapps.com/alight-motion-effects/

    ReplyDelete
  4. Idle Office Tycoon Mod APK This article is very impressive and this knowledge is really interesting. If you want to know more about this game visit website.

    ReplyDelete
  5. This article will guide you how to Mask On Alight Motion free of cost

    ReplyDelete
  6. A Pressure Conversion Calculator is a tool used to convert pressure measurements between different units such as atmospheres, pascals, pounds per square inch (psi), and others. Users input the value they want to convert and select the units they're converting from and to. It simplifies calculations in engineering, meteorology, and fluid mechanics, ensuring accurate pressure measurements across different systems. Click here to get this tool

    ReplyDelete
  7. Someone in uk refer me that you can check mcdonald's menu with prices online, is it true?

    ReplyDelete
  8. With Spotify Premium
    , you can enjoy millions of tracks without interruptions while effortlessly adding the subscription to your Vodacom account.

    ReplyDelete
  9. I refer you to read also officialwalkway blogs for latest info

    ReplyDelete
  10. Roof installations are a crucial aspect for Residential of home maintenance and improvement, ensuring both the durability and aesthetic appeal of a property.

    ReplyDelete
  11. The platform offers a diverse range of popular shows and web series sourced from leading streaming services like Netflix, Amazon Prime, and Hulu, tailored to suit the preferences of binge-watchers. loklok apps


    ReplyDelete
  12. Thank you for this amazing post

    ReplyDelete
  13. I love reading things like this, so thank you for writing it. A excellent video editor with a variety of motion effects is the CapCUt video editor, and I highly recommend it. So, if you are into capcut video editing then you must know that capcutproapk is providing mod version of the CapCut app.

    ReplyDelete
  14. To create a popup window with input in Android Studio, use the PopupWindow class along with an XML layout for the input field. Inflate the layout and attach it to the PopupWindow, then display it using the showAtLocation() or showAsDropDown() method.

    You can also join user generated channels on Fmwhatsapp apk. If you don't have fmwhatsapp, you can simply download it at gbapps.net website. This app will maximize yoyr messaging experience and offers many privacy options.






    ReplyDelete
  15. lightroom mod apk download premium unlocked old version is a powerful photo editing and management tool that allows photographers to enhance their images with various features. It offers tools for adjusting exposure, contrast, color balance, and more, along with advanced options like presets and filters. Additionally, Lightroom supports organizing photos into collections and provides cloud storage for easy access across devices. Whether you're a beginner or a professional, it's a great choice for improving your photography workflow!

    ReplyDelete
  16. With lotus365 reliability meets simplicity. Explore a platform built with advanced features, secure tools, and an intuitive interface designed to make every interaction effortless.

    ReplyDelete
  17. Addressing concerns related to Pregnancy And Breast Cancer can help reduce anxiety and provide clarity about treatment options and outcomes.

    ReplyDelete
  18. These stylish pendant lights are perfect for late-night study sessions. Pair them with a compact Study Table to illuminate your workspace effectively while adding an element of elegance to your room.

    ReplyDelete
  19. Enjoy a seamless sports experience with winbuzz delivering live scores and comprehensive analysis to keep you engaged and informed.

    ReplyDelete