显示String Arrays的内容

时间:2011-08-09 18:25:49

标签: android

我在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 个答案:

答案 0 :(得分:1)

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