2011-08-09 7 views
1

これは私のOnItemClickメソッドにあります。文字列配列の内容を表示

final String[] links = getResources().getStringArray(R.array.pokemon_stats); 
       String content = links[position]; 
       Intent showContent = new Intent(getApplicationContext(), 
       PokedexViewActivity.class); 
       showContent.setData(content); 
       startActivity(showContent); 

私は.setData(コンテンツ)が好きではありません。私はsetDataがURIのためだと信じています。文字列配列の場合はどうすればよいですか?私がホバーすると、これは正確なエラーです。 The method setData(Uri) in the type Intent is not applicable for the arguments (String)

私はこれにそれを切り替えて、私はポケモンの統計情報を取得することはできません。

public void onItemClick(AdapterView<?> parent, View view, 
         int position, long id) { 
      final String[] links = getResources().getStringArray(R.array.pokemon_stats); 
      String content = links[position]; 
      Intent showContent = new Intent(getApplicationContext(), 
      PokedexViewActivity.class); 
      Bundle extras = getIntent().getExtras(); 
      String pokeStats = extras.getString("MarcsString"); 
      showContent.putExtra(pokeStats, content); 
      startActivity(showContent); 

答えて

1

使用showContent.putExtra("key", value);

+0

キーと値は何でしょうか? –

+0

あなたが出荷する変数を認識することができる名前がキーになります。値はケースに入れて出荷したいデータになります。 'putExtra(" MarcsString "、content); ' –

+0

これは正しい方法ですアクティビティ間で値を渡します。 putStringExtraを使用することもできますが、実際にはこれは関係ありません。他のアクティビティでは、次のようなものを使用して取得します。 'Bundle extras = getIntent()。getExtras(); 文字列pokeStats = extras.getString( "MarcsString"); ' – Rob

関連する問題