在我的项目中,我有三天的数组:
String[] days = {"Friday", "Saturday", "Sunday"};
这些以编程方式添加到ViewFlipper中,如下所示:
ViewFlipper vf = (ViewFlipper) findViewById(R.id.view_flipper);
TextView textview = new TextView[numDays];
LinearLayout layout = new LinearLayout[numDays];
for(int i = 0; i<numDays; i++){
layout[i] = new LinearLayout(this);
vf.addView(layout[i]);
textview[i] = new TextView(this);
textview[i].setText(data.days[i].name);
layout[i].addView(textview[i]);
}
但是当我加载我的应用程序时,当我转到ViewFlipper时,它按此顺序显示:
Friday --- Sunday --- Saturday
有人知道为什么会这样吗?
答案 0 :(得分:0)
String[] days = {"Friday", "Saturday", "Sunday"};
和
strong text Intent intent=getIntent();
String selected=intent.getStringExtra("SELECTED",0);
int[] Ids=days [selected];
System.out.println(selected);
Flipp = (ViewFlipper)findViewById(R.id.viewFlipper);
for(int i=0; i<Ids.length;i++)
{
TextView View=new TextView (this);
View.setImageResource(Ids[i]);
Flipp.addView(View);
}