Created
October 1, 2013 21:36
-
-
Save melihmucuk/6785513 to your computer and use it in GitHub Desktop.
Android - Passing data between two activities
This file contains hidden or 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
| private String aktarilanVeri; |
This file contains hidden or 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
| private Bundle veriler; |
This file contains hidden or 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
| final Button GecisButonu = (Button)findViewById(R.id.button1); |
This file contains hidden or 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
| GecisButonu.setOnClickListener(new View.OnClickListener() { | |
| public void onClick(View v) { | |
| bundle.putString("key", "String deger"); | |
| intent.putExtras(bundle); | |
| startActivity(intent); | |
| } | |
| }); |
This file contains hidden or 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
| veriler = getIntent().getExtras(); |
This file contains hidden or 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
| aktarilanVeri = veriler.getString("key"); |
This file contains hidden or 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
| private Intent intent; |
This file contains hidden or 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
| intent = new Intent(OrnekActivity.this,VeriActivity.class); |
This file contains hidden or 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 OrnekActivity extends Activity { | |
| private Intent intent; | |
| private Bundle bundle; | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.ornek_activity); | |
| intent = new Intent(OrnekActivity.this,VeriActivity.class); | |
| bundle = new Bundle(); | |
| final Button GecisButonu = (Button)findViewById(R.id.button1); | |
| GecisButonu.setOnClickListener(new View.OnClickListener() { | |
| public void onClick(View v) { | |
| bundle.putString("key", "String deger"); | |
| intent.putExtras(bundle); | |
| startActivity(intent); | |
| } | |
| }); | |
| } | |
| @Override | |
| public boolean onCreateOptionsMenu(Menu menu) { | |
| getMenuInflater().inflate(R.menu.ornek_activity, menu); | |
| return true; | |
| } | |
| } |
This file contains hidden or 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 VeriActivity extends Activity { | |
| private Bundle veriler; | |
| private String aktarilanVeri; | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.veri_activity); | |
| veriler = getIntent().getExtras(); | |
| aktarilanVeri = veriler.getString("key"); | |
| } | |
| @Override | |
| public boolean onCreateOptionsMenu(Menu menu) { | |
| getMenuInflater().inflate(R.menu.activity_veri_activity, menu); | |
| return true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment