Last active
September 16, 2015 07:20
-
-
Save wowiwo1/9330a38d1d083d3ff482 to your computer and use it in GitHub Desktop.
This file contains 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
public class MainActivity extends Activity { | |
final static int USER_EVENT = 1000; | |
Handler handler; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Button btnMakeEvent = (Button) findViewById(R.id.btn); | |
final EditText etInput = (EditText) findViewById(R.id.et); | |
final TextView tvOutput = (TextView) findViewById(R.id.tv); | |
btnMakeEvent.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
Message msg = handler.obtainMessage(); | |
msg.what = USER_EVENT; | |
msg.obj = etInput.getText().toString(); | |
handler.sendMessage(msg); // Message.obtain(handler, MYEVENT); | |
} | |
}); | |
handler = new Handler() { | |
public void handleMessage(Message msg) { | |
switch(msg.what) { | |
case USER_EVENT: | |
tvOutput.setText((String)msg.obj); | |
break; | |
} | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment