2012-03-01 8 views
1

私のアプリでは、ユーザーはカルーセルを回転させます。選択した項目で、各項目ごとに別々のXMLビューを表示する必要があります。カルーセルは、下半分に常に視認可能であり、上半分に視界が見える。私は断片を使うよりも良い方法があると思う。何か案は?次のコードは今のところ機能しませんが、インフレータが行く方法かもしれないが、それを達成するには私を困らせると思う。 case0の後にcase1-case5があります。複数のxmlビューをフラグメントなしで表示

carousel.setOnItemSelectedListener(new OnItemSelectedListener(){ 

     public void onItemSelected(CarouselAdapter<?> parent, View view, 
       int position, long id) { 



      switch(position){ 
      case 0: 
       final View firstview; 
       LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
       firstview = inflater.inflate(R.layout.selected_item, null); 
       break; 
      case 1: 

答えて

2

誰が、私はそれを解決し、この問題に遭遇した場合には:

LayoutInflater inflater = (LayoutInflater) CarouselActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      LinearLayout inflateView = (LinearLayout) findViewById(R.id.InflateParent); 
      View nextView = null; 

      switch(position){ 
      case 0: 
       System.out.println("Case 0"); 
       inflateView.removeAllViews(); 
       nextView = inflater.inflate(R.layout.nextview, null); 
       inflateView.addView(nextView); 
関連する問題