String arr [] = {" 1"," 2"}; string.xml中的数组

时间:2015-06-04 18:32:03

标签: java android arrays xml

LayoutInflater inflater = getLayoutInflater();
view1 = inflater.inflate(R.layout.item_drawer_im`enter code here`age,null);
RoundedImageView imageView1 = (RoundedImageView) view1.findViewById(R.id.photo);
Picasso.with(com.muzoly.vkmusic.AudioList.this)
        .load(vkApiUsers.get(0).photo_200)
        .into(imageView1);
TextView textView = (TextView) view1.findViewById(R.id.text);
textView.setText(vkApiUsers.get(0).first_name + " " + vkApiUsers.get(0).last_name);
mDrawerLayout.setDrawerListener(createDrawerToggle());
String arr[] = {"Популярное", "Мои аудиозаписи", "Рекомендации", "Загрузки","Настройки"};
mDrawerList.setAdapter(null);
mDrawerList.addHeaderView(view1);

这是我的AudioList.java文件。我想从string.xml文件中获取数组文本。

什么是java代码?

1 个答案:

答案 0 :(得分:-1)

解决!谢谢!

java代码:

String arr[] = getResources().getStringArray(R.array.menuu);

的strings.xml

 <string name="popular">Pop</string>
    <string name="recommend">Рекоммендации</string>
    <string name="my_audios">Мои аудиозаписи</string>
    <string name="settings">Настройки</string>
    <string name="downloads">Загрузки</string>

    <string-array name="menuu">
        <item>@string/popular</item>
        <item>@string/recommend</item>
        <item>@string/my_audios</item>
        <item>@string/settings</item>
        <item>@string/downloads</item>
    </string-array>