Android Simple Login Demo
This demo gives an idea of designing Relative Layout. Its a simple Log In demonstration. Which looks pretty as shown here.
main.xml looks as
Source code as comes here
package my.com.android;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class MyAndroid extends Activity implements OnClickListener
{
private EditText tName;
private EditText tPass;
private Button btnEnter, btnExit;
private AlertDialog.Builder alert;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initComponents();
}
private void initComponents()
{
tName = (EditText) findViewById(R.id.tName);
tPass = (EditText) findViewById(R.id.tPass);
btnEnter = (Button)findViewById(R.id.btnEnter);
btnExit = (Button)findViewById(R.id.btnExit);
btnEnter.setOnClickListener(this);
btnExit.setOnClickListener(this);
}
@Override
public void onClick(View v)
{
if(v == btnEnter) { alert = new AlertDialog.Builder(this); alert.setTitle("Welcome"); alert.setMessage("Your Name: " + tName.getText().toString()+ "\nYour Pass:"+tPass.getText().toString());
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
setResult(RESULT_OK);
}
});
alert.show();
}
else if(v == btnExit)
{
finish();
}
}
}
- Labels: Android
- (0) Comments
0 comments:
Post a Comment