Android 使用微调器设置文本对列表中的一项无效,如何解决?

Android 使用微调器设置文本对列表中的一项无效,如何解决?,android,Android,我对下面的代码有一个问题,我有一个微调器,它有三个诗人的名字,当选择一个时,它设置第二个微调器的内容,当从第二个微调器中选择一首诗时,它设置诗歌的文本视图内容。这对每一首诗都有效,除了《巴黎诗集》的判决书,当它被选中时,什么都不起作用,有人知道为什么吗 这是复制和粘贴的字符串的名称 string name="judgement" 代码: //定义变量 纺纱机,纺纱机; 弦乐诗人[]={”、“罗伯特·伯恩斯”、“詹姆斯·比蒂”, “Duncan MacGregor Crerar”}; 字符串Po

我对下面的代码有一个问题,我有一个微调器,它有三个诗人的名字,当选择一个时,它设置第二个微调器的内容,当从第二个微调器中选择一首诗时,它设置诗歌的文本视图内容。这对每一首诗都有效,除了《巴黎诗集》的判决书,当它被选中时,什么都不起作用,有人知道为什么吗

这是复制和粘贴的字符串的名称

string name="judgement"
代码:

//定义变量
纺纱机,纺纱机;
弦乐诗人[]={”、“罗伯特·伯恩斯”、“詹姆斯·比蒂”,
“Duncan MacGregor Crerar”};
字符串Poems1[]={”、“Tam O Shanter”、“友谊地久天长”};
字符串Poems2[]={“,”巴黎审判“,”吟游诗人“};
字符串Poems3[]={“,”纪念Robbie Burns的诗“,
“我的宝尼罗文树”};
文本视图选择诗歌;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//设置为全屏模式
requestWindowFeature(窗口。功能\u无\u标题);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_全屏,
WindowManager.LayoutParams.FLAG(全屏);
//设置内容视图
setContentView(R.layout.Poter);
initialize();//调用此方法
}
公共无效初始化(){
//初始化类中的项
PoetSpinner=(微调器)findViewById(R.id.spPoet);
PoemSpinner=(微调器)findViewById(R.id.spPoem);
//隐藏第二个微调器
设置可见性(View.GONE);
selectedPoem=(TextView)findViewById(R.id.tvSelectedPoem);
//设置阵列适配器
//
//对于每个微调器
ArrayAdapter适配器=ArrayAdapter
.createFromResource(这个,R.array.poter_数组,
android.R.layout.simple\u微调器(项目);
//指定显示选项列表时要使用的布局
setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
//将适配器应用于微调器
PoetSpinner.setAdapter(适配器);
PoetSpinner.setOnItemSelectedListener(此);
PoemSpinner.setOnItemSelectedListener(新的OnItemSelectedListener()){
已选择公共视图(AdapterView父视图、视图、,
内部位置,长id){
Object=parent.getItemAtPosition(位置);
if(“Tam O Shanter”.equals(poem.toString())){
selectedPoem.setText(getString(R.string.tamO));
}
如果(“友谊地久天长”.equals(poem.toString())){
selectedPoem.setText(getString(R.string.auld));
}
如果(“巴黎的审判”。等于(诗。toString()){
selectedPoem.setText(getString(R.string.determination));
}
如果(“吟游诗人”.equals(poem.toString())){
selectedPoem.setText(getString(R.string.minstrel));
}
if(“纪念Robbie Burns的诗”。equals(Poem.toString())){
selectedPoem.setText(getString(R.string.rob));
}
如果(“我的邦妮·罗文树”.equals(poem.toString())){
selectedPoem.setText(getString(R.string.row));
}
}
未选择公共无效(AdapterView arg0){
//TODO自动生成的方法存根
}
});
}
已选择公共视图(AdapterView父视图、视图、int pos、,
长id){
ArrayAdapter适配器=空;
开关(pos){
案例1:
adapter=ArrayAdapter.createFromResource(此,
R.array.poem_arrays1,android.R.layout.simple_微调器_项);
打破
案例2:
adapter=ArrayAdapter.createFromResource(此,
R.array.poem_arrays2,android.R.layout.simple_微调器_项);
打破
案例3:
adapter=ArrayAdapter.createFromResource(此,
R.array.poem_arrays3,android.R.layout.simple_微调器_项);
打破
违约:
//隐藏诗歌旋转器
设置可见性(View.GONE);
打破
}
if(适配器!=null){
//设置诗歌微调器内容并显示微调器
setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
PoemSpinner.setAdapter(适配器);
设置可见性(View.VISIBLE);
}
XML文件

    <string name="tamO">
But pleasures are like poppies spread, 
You seize the flower, its bloom is shed; 
Or like the snow falls in the river, 
A moment white--then melts for ever; 
Or like the borealis race, 
That flit ere you can point their place; 
Or like the rainbow\'s lovely form 
Evanishing amid the storm.-- 
Nae man can tether time or tide; 
The hour approaches Tam maun ride; 
That hour, o\' night\'s black arch the key-stane, 
That dreary hour he mounts his beast in; 
And sic a night he taks the road in 
As ne\'er poor sinner was abroad in.
</string>
<string name="auld">
For auld lang syne, my dear, 
For auld lang syne. 
We\'ll tak a cup o\' kindness yet, 
For auld lang syne. 

And surely ye\'ll be your pint stowp! 
And surely I\'ll be mine! 
And we\'ll tak a cup o\'kindness yet, 
For auld lang syne. 

We twa hae run about the braes, 
And pou\'d the gowans fine; 
But we\'ve wander\'d mony a weary fit, 
Sin\' auld lang syne. 
</string>
<string name="judgement">
Up the broad cliffs, that tower\'d immense to heaven,
Green wav\'d the lofty pines, on every side;
Save where, fair-opening to the beam of even,
A dale sloped gradual to the valley wide.

Echoed the vale with many a chearful note;
The various lowe of herds resounding long,
The shrilling pipe, the mellow horn remote,
And social clamours of the festive throng.

For now, low-hovering o\'er the western main, 
Where amber clouds begirt his dazzling throne,
The sun with ruddier verdure deck\'d the plain;
And lakes, and streams, and spires triumphal shone;
</string>
<string name="minstrel">
    Of chance or change O let not man complain,
Else shall he never never cease to wail:
For, from th\' imperial dome, to where the swain
Rears the lone cottage in the silent dale,
All feel th\' assault of fortune\'s fickle gale;
Art, empire, earth itself, to change are doom\'d;
Earthquakes have raised to heaven the humble vale,
And gulphs the mountain\'s mighty mass entomb\'d,
And where th\' Atlantick rolls wide continents have bloom\'d.

But sure to foreign climes we need not range,
Nor search the antient records of our race,
To learn the dire effects of time and change,
Which in ourselves, alas, we daily trace.
Yet at the darken\'d eye, the wither\'d face,
Or hoary hair, I never will repine:
But spare, O Time, whate\'er of mental grace,
Of candour, love, or sympathy divine,
Whate\'er of fancy\'s ray, or friendship\'s flame is mine.
</string>  
<string name="rob">
He touched our country\’s ancient harp
With truest patriotic fire;
Forth thrilling came soul-stirring strains,
Man\’s nobler actions to inspire.
The cottar\’s fireside, \‘neath his spell,
Becomes at once a hallowed shrine;
His  hymn to Mary swells the heart,
And fills the eye his Auld Lang Syne.

Not to his native land alone
His genius and his fame belong,
In other climes is treasured dear
His matchless legacy of song.
His melodies have echoing gone
To continents and isles afar;
 They  cheer and gladden hearts alike
\‘Neath Southern Cross and Polar Star.

</string>

<string name="row">
Thrice welcome sweet green spray
Culled from my Rowan Tree,  
By loved ones far away,
In Bonnie Amulree.

 In Boyhood\’s days thy root
Was planted by my hand;
Just ere I left my dear,
My Scottish fatherland.

Thou but a sapling then,
Though now a sheltering tree,
While warblers in thy boughs,
Sing sweetest melodies.
</string>

<string-array name="film_arrays">
    <item>Please Select...</item>
    <item>Sean Connery</item>
    <item>Billy Connolly</item>
    <item>James McAvoy</item>
    <item>Karen Gillan</item>
    <item>Kelly Macdonald</item>
    <item>Ashley Jensen</item>
</string-array>

<string-array name="poet_arrays">
    <item>Please Select...</item>
    <item>Robert Burns</item>
    <item>James Beattie</item>
    <item>Duncan MacGregor Crerar</item>
</string-array>

    <string-array name="poem_arrays1">
    <item>Please Select...</item>
    <item>Tam O Shanter</item>
    <item>Auld Lang Syne</item>
</string-array> 
    <string-array name="poem_arrays2">
    <item>Please Select...</item>
    <item>Judgment Of Paris</item>
    <item>The Minstrel</item>
</string-array>
    <string-array name="poem_arrays3">
    <item>Please Select a...</item>
    <item>A Poem Commemorating Robbie Burns</item>
    <item>My Bonnie Rowan Tree</item>
</string-array>

但快乐就像罂粟花一样蔓延,
你抓住了花朵,它的花开了;
或者像河中的雪一样,
一瞬间变白,然后永远融化;
或者像北方人一样,
你还没来得及指出他们的位置;
或者像彩虹的可爱形状
在风暴中消失
没有人能束缚时间或潮汐;
时间接近谭茂骑行;
那一刻,黑夜的黑拱门,关键的斯坦,
在那个沉闷的时刻,他骑上了他的野兽;
有一天晚上他在路上
因为没有一个可怜的罪人在国外。
为了友谊地久天长,亲爱的,
为了友谊地久天长。
我们还得喝一杯“仁慈”,
为了友谊地久天长。
你一定会成为你的酒鬼!
我一定是我的!
我们还得喝一杯,
为了友谊地久天长。
我们在布雷斯附近跑过,
把高旺家的好东西都倒了;
但我们一直徘徊在疲惫中,
罪恶“友谊地久天长”。
在宽阔的悬崖上,那座塔直达天堂,
四面青松起伏;
除此之外,公平开放的光束,
一个山谷逐渐向山谷宽倾斜。
山谷里回荡着许多凄厉的音符;
各种各样的牛群在长鸣,
刺耳的笛声,圆润的喇叭声,
节日人群的社会喧嚣。
现在,低空盘旋在西干道上,
琥珀色的云朵孕育了他耀眼的王座,
阳光以更加红润的绿色覆盖着平原;
湖光山色,溪流和塔尖都闪耀着胜利的光芒;
机会或变化,不要让人抱怨,
否则他将永远不会停止哭泣:
因为,从帝国的圆顶到天鹅
在寂静的山谷里,养育着孤零零的小屋,
所有人都感受到命运的变化无常的狂风的袭击;
艺术,帝国,地球本身,改变都是厄运;
地震把卑微的山谷升到了天堂,
山上浩瀚的群山掩埋着深渊,
在那里,大西洋滚动着广阔的大陆。
但肯定是外国的气候我们不需要,
也不查我们种族的历史记录,
要了解时间和变化的可怕影响,
唉,我们每天都在自己身上寻找。
然而
    <string name="tamO">
But pleasures are like poppies spread, 
You seize the flower, its bloom is shed; 
Or like the snow falls in the river, 
A moment white--then melts for ever; 
Or like the borealis race, 
That flit ere you can point their place; 
Or like the rainbow\'s lovely form 
Evanishing amid the storm.-- 
Nae man can tether time or tide; 
The hour approaches Tam maun ride; 
That hour, o\' night\'s black arch the key-stane, 
That dreary hour he mounts his beast in; 
And sic a night he taks the road in 
As ne\'er poor sinner was abroad in.
</string>
<string name="auld">
For auld lang syne, my dear, 
For auld lang syne. 
We\'ll tak a cup o\' kindness yet, 
For auld lang syne. 

And surely ye\'ll be your pint stowp! 
And surely I\'ll be mine! 
And we\'ll tak a cup o\'kindness yet, 
For auld lang syne. 

We twa hae run about the braes, 
And pou\'d the gowans fine; 
But we\'ve wander\'d mony a weary fit, 
Sin\' auld lang syne. 
</string>
<string name="judgement">
Up the broad cliffs, that tower\'d immense to heaven,
Green wav\'d the lofty pines, on every side;
Save where, fair-opening to the beam of even,
A dale sloped gradual to the valley wide.

Echoed the vale with many a chearful note;
The various lowe of herds resounding long,
The shrilling pipe, the mellow horn remote,
And social clamours of the festive throng.

For now, low-hovering o\'er the western main, 
Where amber clouds begirt his dazzling throne,
The sun with ruddier verdure deck\'d the plain;
And lakes, and streams, and spires triumphal shone;
</string>
<string name="minstrel">
    Of chance or change O let not man complain,
Else shall he never never cease to wail:
For, from th\' imperial dome, to where the swain
Rears the lone cottage in the silent dale,
All feel th\' assault of fortune\'s fickle gale;
Art, empire, earth itself, to change are doom\'d;
Earthquakes have raised to heaven the humble vale,
And gulphs the mountain\'s mighty mass entomb\'d,
And where th\' Atlantick rolls wide continents have bloom\'d.

But sure to foreign climes we need not range,
Nor search the antient records of our race,
To learn the dire effects of time and change,
Which in ourselves, alas, we daily trace.
Yet at the darken\'d eye, the wither\'d face,
Or hoary hair, I never will repine:
But spare, O Time, whate\'er of mental grace,
Of candour, love, or sympathy divine,
Whate\'er of fancy\'s ray, or friendship\'s flame is mine.
</string>  
<string name="rob">
He touched our country\’s ancient harp
With truest patriotic fire;
Forth thrilling came soul-stirring strains,
Man\’s nobler actions to inspire.
The cottar\’s fireside, \‘neath his spell,
Becomes at once a hallowed shrine;
His  hymn to Mary swells the heart,
And fills the eye his Auld Lang Syne.

Not to his native land alone
His genius and his fame belong,
In other climes is treasured dear
His matchless legacy of song.
His melodies have echoing gone
To continents and isles afar;
 They  cheer and gladden hearts alike
\‘Neath Southern Cross and Polar Star.

</string>

<string name="row">
Thrice welcome sweet green spray
Culled from my Rowan Tree,  
By loved ones far away,
In Bonnie Amulree.

 In Boyhood\’s days thy root
Was planted by my hand;
Just ere I left my dear,
My Scottish fatherland.

Thou but a sapling then,
Though now a sheltering tree,
While warblers in thy boughs,
Sing sweetest melodies.
</string>

<string-array name="film_arrays">
    <item>Please Select...</item>
    <item>Sean Connery</item>
    <item>Billy Connolly</item>
    <item>James McAvoy</item>
    <item>Karen Gillan</item>
    <item>Kelly Macdonald</item>
    <item>Ashley Jensen</item>
</string-array>

<string-array name="poet_arrays">
    <item>Please Select...</item>
    <item>Robert Burns</item>
    <item>James Beattie</item>
    <item>Duncan MacGregor Crerar</item>
</string-array>

    <string-array name="poem_arrays1">
    <item>Please Select...</item>
    <item>Tam O Shanter</item>
    <item>Auld Lang Syne</item>
</string-array> 
    <string-array name="poem_arrays2">
    <item>Please Select...</item>
    <item>Judgment Of Paris</item>
    <item>The Minstrel</item>
</string-array>
    <string-array name="poem_arrays3">
    <item>Please Select a...</item>
    <item>A Poem Commemorating Robbie Burns</item>
    <item>My Bonnie Rowan Tree</item>
</string-array>
<poet name="Robert Burns">
    <poem name="Tam O Shanter">
        But pleasures are like poppies spread, 
        [...] 
    </poem>
    <poem name="Auld Lang Syne">
        For auld lang syne, my dear,
        [...] 
    </poem>
</poet>