public class Main extends Activity
{
private final static String USERNAME = "user1";
private final static String PASSWORD = "12345678";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.page1);
final EditText usernameInput = (EditText) findViewById(R.id.username);
EditText passwordInput = (EditText) findViewById(R.id.password);
passwordInput.addTextChangedListener(new TextWatcher()
{
@Override
public void afterTextChanged(Editable input)
{
if (USERNAME.equals(usernameInput.getText().toString()) && PASSWORD.equals(input.toString()))
{
setContentView(R.layout.page2);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
}
});
}
}
page1.xml
<?xml version="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:gravity="center">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="username:" />
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="password:" />
<EditText
android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
이 실제로 자신의 질문에 올바른 암호가있는 경우이 단지 자동 로그를 응답하지 않습니다
<?xml version="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">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Login successful." />
</LinearLayout>
page2.xml 입력. 그 짧은 또는 잘못 철자 (그러나 더 긴 경우) 당신이 그것을 bruteforce 수있는 큰 보안 위험이 될 수도, – Mgamerz