Skip to content

Instantly share code, notes, and snippets.

@agiletalk
Created April 11, 2011 10:54
Show Gist options
  • Save agiletalk/913357 to your computer and use it in GitHub Desktop.
Save agiletalk/913357 to your computer and use it in GitHub Desktop.
[예제] Button, EditText
package org.catchabug.ButtonEdit;
import android.app.Activity;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
public class ButtonEdit extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn = (Button)findViewById(R.id.btn);
btn.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
EditText edit = (EditText)findViewById(R.id.edit);
String str = edit.getText().toString();
Toast.makeText(ButtonEdit.this, str, Toast.LENGTH_SHORT).show();
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/edit"
android:text="여기다 입력"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn"
android:text="입력 완료"
/>
</LinearLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment