Created
January 1, 2010 18:32
-
-
Save croach/267193 to your computer and use it in GitHub Desktop.
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.android.hello; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.widget.Button; | |
import android.widget.TextView; | |
import android.widget.EditText; | |
import android.widget.LinearLayout; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
public class HelloAndroid extends Activity | |
{ | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
final EditText editText = new EditText(this); | |
editText.setWidth(240); | |
final TextView textView = new TextView(this); | |
Button button = new Button(this); | |
button.setText("Click Me"); | |
button.setOnClickListener(new Button.OnClickListener() { | |
public void onClick(View v) { | |
textView.setText(editText.getText()); | |
} | |
}); | |
LinearLayout form = new LinearLayout(this); | |
LinearLayout main = new LinearLayout(this); | |
main.setOrientation(LinearLayout.VERTICAL); | |
form.addView(editText); | |
form.addView(button); | |
main.addView(form); | |
main.addView(textView); | |
setContentView(main); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment