Skip to content

Instantly share code, notes, and snippets.

@croach
Created January 1, 2010 18:32
Show Gist options
  • Save croach/267193 to your computer and use it in GitHub Desktop.
Save croach/267193 to your computer and use it in GitHub Desktop.
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