本文主要是介绍PHP后端android项目(二)登录界面,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
PHP后端android项目(二)登录界面
代码:
https://code.csdn.net/u012995856/androidpro/tree/master
效果:
xml文件布局:
Android Studio IDE用户体验很好.每项功能都便于开发者.
activity_login.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:id="@+id/activity_main"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingBottom="@dimen/activity_vertical_margin"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"tools:context="com.huijiasoft.androidpro.LoginActivity"><LinearLayout
android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentTop="true"android:layout_alignParentStart="true"><ImageView
android:layout_width="match_parent"android:layout_height="wrap_content"app:srcCompat="@drawable/logo"android:id="@+id/imageView" /><LinearLayout
android:orientation="horizontal"android:layout_width="match_parent"android:layout_height="wrap_content"><TextView
android:text="@string/email"android:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/email"android:layout_weight="0.25" /><EditText
android:layout_width="wrap_content"android:layout_height="wrap_content"android:inputType="textEmailAddress"android:labelFor="@id/email"android:ems="10"android:id="@+id/editText2"android:layout_weight="0.25" /></LinearLayout><LinearLayout
android:orientation="horizontal"android:layout_width="match_parent"android:layout_height="wrap_content"><TextView
android:text="@string/password"android:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/pwd"android:layout_weight="1" /><EditText
android:layout_width="wrap_content"android:layout_height="wrap_content"android:inputType="numberPassword"android:labelFor="@id/pwd"android:ems="10"android:id="@+id/editText3"android:layout_weight="1" /></LinearLayout><Button
android:text="@string/login"android:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/btn_login" /></LinearLayout></RelativeLayout>
strings.xml
<resources><string name="app_name">汇佳OA</string><string name="email">邮件</string><string name="password">密码</string><string name="login">登录</string><string name="department">部门</string><string name="staff">员工</string><string name="title_activity_about">AboutActivity</string>
</resources>
LoginActivity.java
package com.huijiasoft.androidpro;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.Toast;import cn.jpush.android.api.JPushInterface;/*author:pangPythonfunc: 登录界面的逻辑代码**/
public class LoginActivity extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_login);//初始化JPush极光推送SDKJPushInterface.setDebugMode(true);JPushInterface.init(this);//登录按钮final Button btn_login = (Button) findViewById(R.id.btn_login);//按钮点击监听器btn_login.setOnClickListener(login_onclickListener);}//登录事件private View.OnClickListener login_onclickListener = new View.OnClickListener(){@Overridepublic void onClick(View view) {//弹出toastToast.makeText(getApplicationContext(),"登录成功!",Toast.LENGTH_LONG).show();//跳转进入MainActivityIntent intent = new Intent(LoginActivity.this,MainActivity.class);LoginActivity.this.startActivity(intent);}};}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.huijiasoft.androidpro"><!-- Required --><permission
android:name="com.huijiasoft.androidpro.permission.JPUSH_MESSAGE"android:protectionLevel="signature" /><!-- Required 一些系统要求的权限,如访问网络等--><uses-permission android:name="com.huijiasoft.androidpro.permission.JPUSH_MESSAGE" /><uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.WAKE_LOCK" /><uses-permission android:name="android.permission.READ_PHONE_STATE" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.WRITE_SETTINGS" /><uses-permission android:name="android.permission.VIBRATE" /><uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><!-- Optional for location --><uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 --><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /><uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /><uses-permission android:name="android.permission.GET_TASKS" /><application
android:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:supportsRtl="true"android:theme="@style/AppTheme"><activity android:name=".LoginActivity"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activity android:name=".MainActivity" /><activity android:name=".DepartmentActivity" /><activity android:name=".StaffActivity" /><activity android:name=".ProjectActivity" /><activity android:name=".NewsActivity" /><activity android:name=".NoticeActivity" /><activity android:name=".HonorActivity" /><activity android:name=".AchievementActivity" /><activity android:name=".SetupActivity" /><activity
android:name=".AboutActivity"android:label="@string/title_activity_about"android:theme="@style/AppTheme.NoActionBar"></activity></application></manifest>
声明APP中要用到的权限,注册每一个Activity
相应Activity如果要作为第一个启动,把
<intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter>
加入相应的Activity节点中.
这篇关于PHP后端android项目(二)登录界面的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!