2
내 앱의 Android 지원 라이브러리에서 ViewPager를 구현했는데 어떤 이유로 그것이 보이지 않습니다. 앱 레이아웃은 약간 중첩되어있어 일부 문제가 발생합니다. 나는 그것을 의미있는 코드로 압축하려고 노력할 것이다. 내 레이아웃 인플레이션 코드 :Android 지원 ViewPager가 보이지 않습니다.
LinearLayout ll = (LinearLayout) findViewById(R.id.root);
View v = getLayoutInflater().inflate(R.layout.project_row, null);
TextView header = (TextView) v.findViewById(R.id.rowheader);
header.setText(rowHeader);
ViewPager projectRow = (ViewPager) v.findViewById(R.id.pager);
projectRow.setAdapter(new ProjectPagerAdapter(tiles));
LinePageIndicator lineIndicator = (LinePageIndicator)v.findViewById(R.id.pagerIndicator);
lineIndicator.setViewPager(projectRow);
lineIndicator.setStrokeWidth(7);
lineIndicator.setLineWidth(50);
lineIndicator.setSelectedColor(Color.parseColor("#555555"));
lineIndicator.setUnselectedColor(Color.parseColor("#DCDCDC"));
ll.addView(v);
project_row.xml :
LinearLayout ll = (LinearLayout) findViewById(R.id.root);
View v = getLayoutInflater().inflate(R.layout.pageronlytest, null);
ViewPager vp = (ViewPager)v.findViewById(R.id.pager);
vp.setAdapter(new ProjectPagerAdapter(tiles));
ll.addView(v);
pageronlytest.xml :
나는이 인플레이션 코드를 사용하는 경우 ViewPager 자체로 작동<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/rowheader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/SectionHeaderColor" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="280dp" />
<com.viewpagerindicator.LinePageIndicator
android:id="@+id/pagerIndicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="280dp"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="280dp" />
</LinearLayout>
완벽하게 작동했습니다! 나는 그것을 보지 못했다고 믿을 수 없다. – Logiraptor
훌륭한 통찰력의 남자 ....이 대답에 정말 만족합니다! –