A. 高價急求一個安卓程序(簡單的登陸界面和注冊界面)源碼和程序 教程也可以
1
MainActivity
@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button dengluButton =(Button)findViewById(R.id.button1);
Button zhuceButton=(Button)findViewById(R.id.button2);
final EditText yonghumingEditText=(EditText) findViewById(R.id.editText1);
final EditText mimaEditText=(EditText) findViewById(R.id.editText2);
zhuceButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setClass(MainActivity.this, ZhuceActivity.class);
startActivity(intent);
}
});
dengluButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
FileInputStream fis;
try {
fis = new
FileInputStream(Environment.getExternalStorageDirectory().getParent()+"/"+yonghumingEditText.getText().toString());
byte[] input =new byte[fis.available()];
while(fis.read(input)!=-1);
fis.close();
String mimastring=new String(input);
if (mimastring.equals(mimaEditText.getText().toString())==true) {
Toast.makeText(getApplicationContext(), new String(input),Toast.LENGTH_SHORT).show();
String mimaString= new String(input);
if (mimastring.equals(mimaEditText.getText().toString())==true) {
Toast.makeText(getApplicationContext(), "成功登陸", Toast.LENGTH_SHORT).show();
Intent intent =new Intent();
intent.setClass(MainActivity.this,ZhuceActivity.class );
startActivity(intent);
}
else {
Toast.makeText(getApplicationContext(), "用戶名或密碼錯誤", Toast.LENGTH_SHORT).show();
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent intent=new Intent(MainActivity.this,AbActivity.class);
startActivity(intent);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
2. ZhuceActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zhuce);
Button zhucebingfanhuiButton = (Button) findViewById(R.id.button1);
final EditText yonghumingEditText=(EditText) findViewById(R.id.editText1);
final EditText mimaEditText=(EditText) findViewById(R.id.editText2);
zhucebingfanhuiButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
File writeFile=new File(Environment.getExternalStorageDirectory().getPath(),yonghumingEditText.getText().toString());
if (!writeFile.exists()) {
try {
writeFile.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
String abcString =mimaEditText.getText().toString();
FileOutputStream fos;
try {
fos=new FileOutputStream(writeFile);
fos.write(abcString.getBytes());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent intent= new Intent();
intent.setClass(ZhuceActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.zhuce, menu);
return true;
}
}
三、
package com.example.zhuanhuan;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import com.example.zhuanhuan.MainActivity;
import com.example.zhuanhuan.R;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class KkkActivity extends Activity {
private File writeFile;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.kkk);
Button backButton = (Button) findViewById(R.id.button1);
final EditText yonghumingEditText = (EditText) findViewById(R.id.editText1);
final EditText mimaEditText = (EditText) findViewById(R.id.editText2);
backButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
File writeFile = new File(Environment.getExternalStorageDirectory().getPath(), yonghumingEditText.getText().toString());
if (!writeFile.exists()) {
try {
writeFile.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
String abcString = mimaEditText.getText().toString();
FileOutputStream fos;
try {
fos = new FileOutputStream(writeFile);
fos.write(abcString.getBytes());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent intent = new Intent();
intent.setClass(KkkActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.kkk, menu);
return true;
}
}
四、
package com.example.zhuanhuan;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class AaaActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.aaa);
Button jianceButton = (Button) findViewById(R.id.button1);
jianceButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(AaaActivity.this, qqqActivity.class);
startActivity(intent);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.aaa, menu);
return true;
}
}
B. 如何使用Android Studio開發用戶登錄界面
activity_register.xml:
<?xmlversion="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="
xmlns:tools="
android:id="@+id/activity_redister"
android:layout_width="match_parent"
android:orientation="vertical"
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.example.weijun.test0321.RegisterActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用戶名:"
android:textSize="25sp"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/please_input_user_name"
android:id="@+id/input_user_name"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密碼:"
android:textSize="25sp"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="請輸入密碼"
android:id="@+id/input_user_password"
/>
</LinearLayout>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/rg">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="男"
android:id="@+id/boy"
android:layout_weight="1"
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女"
android:layout_weight="1"
android:id="@+id/girl"
/>
</RadioGroup>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="注冊"
android:id="@+id/bn_register"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
</LinearLayout>
activity_login.xml:
<?xmlversion="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="
android:orientation="vertical"android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="登陸界面"
android:textSize="38sp"
/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用戶名:"
android:textSize="25sp"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/user_name"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密碼:"
android:textSize="25sp"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/user_password"
/>
</LinearLayout>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="記住密碼?"
android:id="@+id/remember_password"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登陸"
android:id="@+id/bn_login"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_register"
android:text="注冊賬號"
android:layout_alignParentBottom="true"
android:textColor="@color/colorAccent"
/>
</RelativeLayout>
</LinearLayout>
MyOpenHelper.java:
{
publicMyOpenHelper(Contextcontext){
super(context,"info.db",null,1);
}
@Override
publicvoidonCreate(SQLiteDatabasedb){
db.execSQL("createtableinfo(_,namevarchar(20),passwordvarchar(20),sexvarchar(20))");
}
@Override
publicvoidonUpgrade(SQLiteDatabasedb,intoldVersion,intnewVersion){
}
}
registerActivity.java:
{
privateEditTextet_name,et_password;
privateRadioGrouprg;
privateButtonbn_register;
;
privateSQLiteDatabasedatabase;
privateCheckBoxcb_remember_password;
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
initUI();
initListener();
}
privatevoidinitListener(){
bn_register.setOnClickListener(newView.OnClickListener(){
@Override
publicvoidonClick(Viewv){
Stringget_name=et_name.getText().toString().trim();
Stringget_password=et_password.getText().toString().trim();
if(TextUtils.isEmpty(get_name)||TextUtils.isEmpty(get_password)){
Toast.makeText(RegisterActivity.this,"請輸入用戶名或密碼",Toast.LENGTH_SHORT).show();
}else{
inttemp=rg.getCheckedRadioButtonId();
intsex=0;
switch(temp){
caseR.id.boy:
sex=1;
break;
caseR.id.girl:
sex=2;
break;
}
if(sex==0){
Toast.makeText(RegisterActivity.this,"請選擇性別",Toast.LENGTH_SHORT).show();
}elseif(sex==1){
myOpenHelper=newMyOpenHelper(RegisterActivity.this);
database=myOpenHelper.getReadableDatabase();
ContentValuesvalues=newContentValues();
values.put("name",get_name);
values.put("password",get_password);
values.put("sex","男");
database.insert("info",null,values);
}else{
myOpenHelper=newMyOpenHelper(RegisterActivity.this);
database=myOpenHelper.getReadableDatabase();
ContentValuesvalues=newContentValues();
values.put("name",get_name);
values.put("password",get_password);
values.put("sex","女");
database.insert("info",null,values);
}
}
}
});
}
privatevoidinitUI(){
et_name=(EditText)findViewById(R.id.input_user_name);
et_password=(EditText)findViewById(R.id.input_user_password);
rg=(RadioGroup)findViewById(R.id.rg);
bn_register=(Button)findViewById(R.id.bn_register);
}
}
loginActivity.java貼不上來,超過字數了。
C. android怎麼做動態的登陸界面
設計android的登錄界面的方法:
UI實現的代碼如下:
1、背景設置圖片:
background_login.xml
<?xmlversion="1.0"encoding="utf-8"?>
<shapexmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#FFACDAE5"
android:endColor="#FF72CAE1"
android:angle="45"
/>
</shape>
2、圓角白框
效果圖上面的並不是白框,其實框是白色的,只是設置了透明值,也是靠一個xml文件實現的。
background_login_div.xml
<?xmlversion="1.0"encoding="UTF-8"?>
<shapexmlns:android="http://schemas.android.com/apk/res/android">
<solidandroid:color="#55FFFFFF"/>
<!--設置圓角
注意:bottomRightRadius是左下角而不是右下角bottomLeftRadius右下角-->
<cornersandroid:topLeftRadius="10dp"android:topRightRadius="10dp"
android:bottomRightRadius="10dp"android:bottomLeftRadius="10dp"/>
</shape>
3、界面布局:
login.xml
<?xmlversion="1.0"encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_login">
<!--padding內邊距layout_margin外邊距
android:layout_alignParentTop布局的位置是否處於頂部-->
<RelativeLayout
android:id="@+id/login_div"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="15dip"
android:layout_margin="15dip"
android:background="@drawable/background_login_div_bg">
<!--賬號-->
<TextView
android:id="@+id/login_user_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp"
android:text="@string/login_label_username"
style="@style/normalText"/>
<EditText
android:id="@+id/username_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/login_username_hint"
android:layout_below="@id/login_user_input"
android:singleLine="true"
android:inputType="text"/>
<!--密碼text-->
<TextView
android:id="@+id/login_password_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/username_edit"
android:layout_marginTop="3dp"
android:text="@string/login_label_password"
style="@style/normalText"/>
<EditText
android:id="@+id/password_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/login_password_input"
android:password="true"
android:singleLine="true"
android:inputType="textPassword"/>
<!--登錄button-->
<Button
android:id="@+id/signin_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/password_edit"
android:layout_alignRight="@id/password_edit"
android:text="@string/login_label_signin"
android:background="@drawable/blue_button"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextViewandroid:id="@+id/register_link"
android:text="@string/login_register_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:textColor="#888"
android:textColorLink="#FF0066CC"/>
<ImageViewandroid:id="@+id/miniTwitter_logo"
android:src="@drawable/cat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="25dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="25dp"/>
<ImageViewandroid:src="@drawable/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/miniTwitter_logo"
android:layout_alignBottom="@id/miniTwitter_logo"
android:paddingBottom="8dp"/>
</RelativeLayout>
</LinearLayout>
4、java源代碼,Java源文件比較簡單,只是實例化Activity,去掉標題欄。
packagecom.mytwitter.acitivity;
importandroid.app.Activity;
importandroid.os.Bundle;
importandroid.view.Window;
{
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.login);
}
}
5、實現效果如下:
D. Android登錄界面點擊登錄顯示登錄成功對話框,點擊取消關掉對話框,求代碼怎麼寫
Button btn = (Button)this.findViewById(R.id.btn);
btn.setText("登陸");
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage("登陸成功").setCancelable(false).setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
return;
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
E. 用eclipse開發安卓應用,現在只做了個界面。請問在點擊「登錄」以後怎麼跳轉頁面,代碼怎麼寫,怎
在 onClick中寫
Intent intent = new Intent(LoginActivity.this, HelloWorldActivity.class);
startActivity(intent);
假定你當前的類叫回LoginActivity,要啟動答的叫HelloWorldActivity
F. 如何使用Android Studio開發用戶登錄界面
一個登錄界面需要有:
登錄、注冊按鈕(Button)
用戶名、密碼輸入框(TextView,EditView)
用戶協議連接
忘記密碼按鈕
想好的有哪些控制項後,開始設計界面大概樣式,比如這個樣子:
安卓登錄界面就寫完了。
G. 如何使用Android Studio開發用戶登錄界面
使用Android Studio開發用戶登錄界面是可以直接創建的,創建步驟如下。
1、點擊菜單欄的「File」-->"New"-->「New Project 」。