Created
June 15, 2013 03:00
-
-
Save emedinaa/5786679 to your computer and use it in GitHub Desktop.
Android Example 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.area51.proyects.papphelloworld; | |
import android.os.Bundle; | |
import android.app.Activity; | |
import android.util.Log; | |
import android.view.Menu; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
import android.widget.Toast; | |
public class MainActivity extends Activity implements OnClickListener{ | |
private Button btn1; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
app(); | |
} | |
private void app() { | |
// TODO Auto-generated method stub | |
//inicializar variables | |
btn1=(Button)findViewById(R.id.button1); | |
//events | |
btn1.setOnClickListener(this); | |
} | |
@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 void onClick(View v) { | |
// TODO Auto-generated method stub | |
switch (v.getId()) | |
{ | |
case R.id.button1: | |
Log.v("console", "click"); | |
Toast.makeText(this, "Click", Toast.LENGTH_LONG).show(); | |
break; | |
default: | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment