2012-02-17 5 views
1

ViewPagerIndicator(http://viewpagerindicator.com/)を使用しようとすると、非常に奇妙なエラーが発生します。私はそれをそのライブラリの一部であるTitlePageIndicatorに絞り込んだ。 TitlePageIndicatorを使用すると、タブ間でスワイプできず、フラグメントが表示されません(作成して実行しましたが、右上のボタンは表示するフラグメントによって作成されます)。 http://imgur.com/RJaI9(申し訳ありません、新規ユーザーのため、私はインラインで画像を表示できません)ViewPagerIndicatorのTitlePageIndicatorがフラグメントの表示を停止し、スワイプが動作しないようにします。

しかし、私の断片は正しく表示され、それらの間をスワイプすることができます。 http://imgur.com/bboSd

なぜこれが起こっているのかわかりません。私は最新のViewPagerIndicatorライブラリを使用していますが、インポートした方法と関係があるかもしれません。私はウェブサイト上の指示に従った: 既存のソースからEclipseの新しいアンドロイドプロジェクトを作成し、互換性ライブラリをインポートし、それをアンドロイドプロジェクトプロパティのプロジェクトに追加しました。

任意の助けをいただければ幸いです

、私は2週間のために、この上で立ち往生してきた:(

コード:

レイアウト:(ActionBarSherlockから)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 
<com.viewpagerindicator.TitlePageIndicator 
    android:id="@+id/titles" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" /> 
<android.support.v4.view.ViewPager 
    android:id="@+id/grocery_pager" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    /> 
</LinearLayout> 

FragmentActivity:

public class GroceryActivity extends BaseFragmentActivity 
{ 
    @Override 
    protected void onCreate(Bundle savedInstanceState) 
    { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_grocerylist); 
    // Set the pager with an adapter 
    ViewPager pager = (ViewPager) findViewById(R.id.grocery_pager); 
    pager.setAdapter(new GroceryViewPagerAdapter(getSupportFragmentManager())); 

    // Bind the title indicator to the adapter 
//When these next two lines are commented out, everything works 
    TitlePageIndicator titleIndicator = (TitlePageIndicator) findViewById(R.id.titles); 
    titleIndicator.setViewPager(pager); 
    } 
} 

答えて

2

問題が見つかりました:

私の線形レイアウトでは、レイアウトの向きを設定しませんでした。いくつかの愚かな理由のために、私はオリエンテーション場がレイアウト自体ではなく、デバイスの向きと関係していると思った。 orientation:verticalフィールドを追加すると、すべてが機能します。

これは誰かを助けてくれることを願っています。

関連する問題