In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces Android studio how to achieve app login interface related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this Android studio how to achieve app login interface article will have a harvest, let's take a look.
Android studio designs app login interface
UI interface design
When designing the login interface, you can use different layouts to achieve this function, usually using LinearLayout (linear layout) and TableLayout (table layout), and linear layout is used in this article. The login interface requires several essential controls, as follows:
TextView: tips for displaying title and "user name" and "password"
Title Settin
User name prompt
Password prompt:
EditView: used to enter user name and password
User name input box:
Password input box:
Button: used to control login.
Button login button:
/ >
This article uses three layers of LinearLayout to nest each other, and the first layer of LinearLayout includes the title (TextView), the second layer LinearLayout and the login button (Button). The first layer of LinearLayout uses vertical distribution, that is, android:orientation= "vertical".
Two layer 3 LinearLayout are nested in the second layer LinearLayout, and the second layer LinearLayout is vertically distributed, that is, android:orientation= "vertical".
The two LinearLayout in the third layer each contain a TextView and an EditView, and the third layer LinearLayout is a horizontal distribution, that is, android:orientation= "horizontal".
The overall UI design is shown below.
/ >
The effect is shown in the figure.
Java code writing
If the user enters the user name or password incorrectly, the pop-up window prompts "the user name or password is entered incorrectly, please correct it and re-enter it!" .
If the user does not enter a user name or password, the pop-up window prompts "the user name and password cannot be empty!" .
Only when the user name and password are entered correctly at the same time can you enter the system.
Package com.example.activities
Import android.content.Intent
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.Toast
Public class MainActivity extends AppCompatActivity {
Private EditText usertext
Private EditText passtext
Private Button loginbutton
@ Override
Protected void onCreate (Bundle savedInstanceState) {
Super.onCreate (savedInstanceState)
SetContentView (R.layout.activity_main)
Usertext= (EditText) this.findViewById (R.id.ed1)
Passtext= (EditText) this.findViewById (R.id.ed2)
Loginbutton= (Button) this.findViewById (R.id.bt)
Loginbutton.setOnClickListener (new ButtonListener ())
}
Private class ButtonListener implements View.OnClickListener {
@ Override
Public void onClick (View v) {
String user=usertext.getText () .toString ()
String pass=passtext.getText () .toString ()
If (user.equals (") | | pass.equals (")) {
Toast.makeText (MainActivity.this, "username and password cannot be empty!" , Toast.LENGTH_SHORT) .show ()
}
Else if (user.equals ("denglu") & & pass.equals ("0000")) {
Toast.makeText (MainActivity.this, "login succeeded", Toast.LENGTH_SHORT) .show ()
Intent intent=new Intent (MainActivity.this,TwoActivity.class)
StartActivity (intent)
}
Else {
Toast.makeText (MainActivity.this, "user name or password was entered incorrectly, please correct it and re-enter it!" , Toast.LENGTH_SHORT) .show ()
}
}
}
}
After clicking the login button, go to the next interface. Add the name of the second Activity to the Manifest.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.