android - 显示字符串数组的内容

标签 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(content)。我相信 setData 是针对 URI 的。我要为字符串数组做什么?这是我悬停时的确切错误。 Intent 类型中的方法 setData(Uri) 不适用于参数 (String)

我把它切换到这个,但我无法获得宠物小 Sprite 的统计数据:

 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);

最佳答案

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

关于android - 显示字符串数组的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7000985/

相关文章:

android - 条形码读取 Delphi xe7, Intent 未触发后的事件

android - 如何获得Soundpool的持续时间

Android:不显示 ListFragment 中带有自定义 ListAdapter 的 ListView

android - 在android 4.3中使用Robolectric测试BluetoothAdapter

android - 连接到本地数据库时出现 SocketTimeoutException

android - 从通知启动 Activity 后返回主 Activity

android - TabLayout 中的 fragment 仅在用户滑动 Android 时加载

android - Logcat 经常下类

java - flutter_downloader 插件不适用于现有项目

android - 如何在 ionic 应用程序中查找按钮是否处于 Activity 状态