1

在我的项目中,我有一个三天的数组:

 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

有人知道为什么会这样吗?

4

1 回答 1

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);
    }               
于 2012-09-22T12:17:23.017 回答