在我的項目中,listview包含用於加載圖像的viewpager。實際上,這個listview被加載到使用滑動菜單的片段中。列表視圖包含SlidingMenu中的Viewpager -Android
這裏的問題是佈局既不加載也不顯示任何錯誤。
我用pagecontainer這樣S://gist.github.com/devunwired/8cbe094bb7a783e37ad1
我的適配器類
public class SampleAdapter extends BaseAdapter {
private Activity activity;
private String[] titleData;
private int[] imageData;
private ArrayList<Request> List;
PagerContainer mContainer;
MyPagerAdapter adapter;
public SampleAdapter(Activity a, ArrayList<Request> list) {
activity = a;
List = new ArrayList<Request>();
List = list;
}
@Override
public int getCount() {
return List.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.cus_hub_list, parent, false);
mContainer = (PagerContainer) rowView.findViewById(R.id.pager_container);
ViewPager pager = mContainer.getViewPager();
adapter = new MyPagerAdapter();
pager.setAdapter(adapter);
pager.setOffscreenPageLimit(adapter.getCount());
pager.setPageMargin(15);
pager.setClipChildren(false);
return rowView;
}
public class MyPagerAdapter extends PagerAdapter {
@Override
public Object instantiateItem(ViewGroup container, int position)
{
TextView view = new TextView(activity);
view.setText("Item " + position);
view.setGravity(Gravity.CENTER);
view.setBackgroundColor(Color.argb(255, position * 50,
position * 10, position * 50));
container.addView(view);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public int getCount() {
return 5;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return (view == object);
}
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
}
}
但問題列表視圖不顯示任何列表物品。
有人可以找出問題。
在此先感謝。
我的目錄視圖所有示出被適配爲空:( –