<Button
android:id="@+id/btn_one"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="40dp"
android:layout_marginLeft="20dp"
android:text="登陆"
android:gravity="center"
android:background="#8DEEEE"
android:textColor="#FFFFFF"
android:textSize="25sp"
android:textStyle="italic"
android:onClick="CCC" />
<TextView
android:id="@+id/btn1"
android:layout_width="80dp"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="25dp"
android:layout_marginTop="180dp"
android:gravity="center"
android:text="账号 "
android:textColor="#080808"
android:textSize="25sp"
android:textStyle="italic"
/>
<TextView
android:layout_height="50dp"
android:layout_width="80dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="240dp"
android:layout_marginLeft="25dp"
android:textStyle="italic"
android:gravity="center"
android:textSize="25sp"
android:textColor="#080808"
android:text="密码 "
android:id="@+id/btn2"
android:layout_toRightOf="@id/btn1"/>
<EditText
android:id="@+id/mima"
android:layout_width="200dp"
android:layout_height="50dp"
android:hint="请输入密码"
android:textColor="#080808"
android:onClick="click"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="240dp"
android:layout_marginLeft="100dp"
android:inputType="textPassword"
/>
<EditText
android:id="@+id/qq"
android:layout_width="200dp"
android:layout_height="50dp"
android:hint="请输入账号"
android:textColor="#080808"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="180dp"
android:layout_marginLeft="100dp"
/>
</RelativeLayout>
package com.example.wx;
import android.app.Activity;
import android.view.View;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import android.widget.EditText;
import android.content.SharedPreferences;
public class MainActivity extends Activity {
private EditText mEd_qqnum;
private EditText mEd_pwd;
private SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@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;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void CCC(View view) {
String qq=mEd_qqnum.getText().toString().trim();
String pwd=mEd_pwd.getText().toString().trim();
if("123456".equals(qq)&&"123456".equals(pwd))
Toast.makeText(MainActivity.this,"登陆成功",Toast.LENGTH_SHORT).show();
else
Toast.makeText(MainActivity.this,"登陆失败",Toast.LENGTH_SHORT).show();
return;
}
}