如何循环通过R.string。<name>

时间:2017-07-22 04:35:59

标签: android

我试图通过字符串中的以下项循环。但是获得无效的int错误。什么是最佳解决方案或解决方法?

<string name="hero_1">Akshay</string>
<string name="hero_1_number_of_movies">15</string>
<string name="hero_1_children">2</string>

<string name="hero_2">Ajay</string>
<string name="hero_2_number_of_movies">55</string>
<string name="hero_2_children">2</string>

这是我的java类循环:

for (int i=0;i<numberOfchalisas;i++) {
    int heroName = Integer.valueOf("R.string.hero_" + (i + 1));
    int numMoviesDone = Integer.valueOf("hero_"+(i+1)+"_number_of_movies");
    int numChildren = Integer.valueOf("hero_"+(i+1)+"_children");

    String name = getString(heroName);
}

1 个答案:

答案 0 :(得分:1)

这样可行!尝试

passthru('gsutil cp '.$filepath.' gs://bucket/', $status_result);