Skip to content

Instantly share code, notes, and snippets.

@gmsetiawan
Last active August 29, 2015 14:03
Show Gist options
  • Save gmsetiawan/71619f3037a10df40d76 to your computer and use it in GitHub Desktop.
Save gmsetiawan/71619f3037a10df40d76 to your computer and use it in GitHub Desktop.
package com.example.droidclass;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity {
EditText edSent;
Button btnSent;
String note;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_one);
edSent = (EditText) findViewById(R.id.editText1);
btnSent = (Button) findViewById(R.id.button1);
btnSent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
note = edSent.getText().toString();
Intent intent = new Intent(MainActivity.this, ActivityTwo.class);
intent.putExtra("keyName", note); // pass your values and retrieve them in the other Activity using keyName
startActivity(intent);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment