2014-04-04 27 views

回答

1

在你的第一個活動試試這個,

Intent intent = new Intent(MainActivity.this, Player.class); 
String SongName = SpinSongSelector.getSelectedItem().toString(); 
intent.putExtra("message", SongName); 
startActivity(intent); 

,然後在第二個活動讓你的串像下面

Bundle bundle = getIntent().getExtras(); 
String message = bundle.getString("message"); 

然後設置該字符串文本的視圖(這不是NEC埃森只是供大家參考,如果你想查詢你是否得到了正確的字符串或沒有)

TextView txtView = (TextView) findViewById(R.id.your_resource_textview);  
txtView.setText(message); 
+0

Thnk你非常多:) – Awaix

+0

你可以通過點擊接受答案在我的答案下面,因爲你是新手,所以檢查一下,http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – InnocentKiller

0

使用此行startActivty前:

intent.putExtra("SongName",SongName); 

然後從目標activty檢索。

0

只使用

第一個活動送:

Intent in = new Intent(MainActivity.this, Player.class); 
String SongName = SpinSongSelector.getSelectedItem().toString(); 
in.putExtra("data",SongName); 
startActivity (in); 

接收另一個動作:

String Sname = getIntent().getExtras().getString("data"); 

看到意圖的詳情,請參閱這裏:http://developer.android.com/guide/components/intents-filters.html

相關問題