Android’te aktif ekrandaki bilgiyi başka bir ekrana nasıl taşırım?

ekran1


public class MainActivity extends AppCompatActivity {
EditText et;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et= (EditText) findViewById(R.id.editText);
}
public void Tiklendi(View v){
if(v.getId()==R.id.button3){
CharSequence charSequence=et.getText();
if (TextUtils.isEmpty(charSequence)) {
Toast.makeText(getApplicationContext(),"Boş Geçilemez",Toast.LENGTH_LONG).show();
}
else{
Intent intent = new Intent(getApplicationContext(), Ekran3.class);
intent.putExtra("anahtar",charSequence);
startActivity(intent);
}
}
}
}

ekran2


public class Ekran3 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ekran3);
TextView tv= (TextView) findViewById(R.id.textView2);
Bundle gelenveri=getIntent().getExtras();
CharSequence gelenyazi=gelenveri.getCharSequence("anahtar");
tv.setText(gelenyazi);
};
}

ekran3

Etiketler: , ,

Yorum Yapın