2011-08-09 3 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 (content)가 마음에 들지 않습니다. 나는 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(); String pokeStats = extras.getString ("MarcsString"); ' – Rob