Androidログイン機能概要EditText値を取得して比較

1936 ワード

package com.example.qq;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {

	private Button btn;
    private EditText et;
    private EditText et2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
            

        et = (EditText)findViewById(R.id.editText1);
      

        et2 = (EditText)findViewById(R.id.editText2);
        
        
        btn = (Button)findViewById(R.id.button1);
        btn.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
			    final String str = et.getText().toString().trim();
			    final String str2 = et2.getText().toString().trim();
				if (str.equals(str2))
				{
					Intent in = new Intent(MainActivity.this,SecActivity.class);
					startActivity(in);
				}
				else
				{
					System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!");
				}
			}});
    }

	@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;
    }
    
}