package com.example.s03;
import android.os.Bundle;
import android.app.Activity;
import android.support.v4.widget.SimpleCursorAdapter.ViewBinder;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity implements View.OnClickListener{
Button btn_001, btn_002, btn_003;
EditText edit_msg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn_001 = (Button)findViewById(R.id.btn_001);
btn_002 = (Button)findViewById(R.id.btn_002);
btn_003 = (Button)findViewById(R.id.btn_003);
edit_msg = (EditText)findViewById(R.id.edt_msg);
btn_001.setOnClickListener(this);
btn_002.setOnClickListener(this);
btn_003.setOnClickListener(this);
edit_msg.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 arg0) {
// TODO Auto-generated method stub
switch (arg0.getId()){
case R.id.btn_001:
Toast.makeText(this, "단순출력", Toast.LENGTH_LONG).show();
break;
case R.id.btn_002:
if(edit_msg.getText().toString().equals("")){
Toast.makeText(this, "내용을 입력하세요", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, edit_msg.getText().toString(), Toast.LENGTH_LONG).show();
}
break;
case R.id.btn_003:
Toast.makeText(this, "프로그램종료", 2000).show();
finish();
break;
case R.id.edt_msg:
break;
}
}
}
'이전것 > 개발' 카테고리의 다른 글
android -> LifeCycle (0) | 2016.07.07 |
---|---|
android -> binary search game (0) | 2016.07.07 |
android -> Event (0) | 2016.07.07 |
https://play-entry.org/tt#!/basic/solve (0) | 2016.07.06 |
php -> cross array (0) | 2016.07.06 |