gpt4 book ai didi

android - 错误显示在 viewpager 添加 View 中

转载 作者:行者123 更新时间:2023-11-30 03:16:23 24 4
gpt4 key购买 nike

这是 xml 布局 View 寻呼机的 View 寻呼机代码

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

此代码显示包含“((ViewPager) container.addView(viewlayout);”的 View 寻呼机行中的错误,它位于 instantiateItem 函数内以在 View 寻呼机中添加 View 。如何解决此错误请帮忙。

public class Fullscreenimage extends PagerAdapter {
public Integer[] images1 = { R.drawable.s_1, R.drawable.s_2, R.drawable.s_3 };

public Context mContext;

public Fullscreenimage(Context context) {
super();
this.mContext = context;

// TODO Auto-generated constructor stub
}

@Override
public int getCount() {
// TODO Auto-generated method stub
return 0;
}

@Override
public boolean isViewFromObject(View arg0, Object arg1) {
// TODO Auto-generated method stub
return false;
}

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
// TODO Auto-generated method stub
super.destroyItem(container, position, object);
}

@Override
public Object instantiateItem(ViewGroup container, int position) {
// TODO Auto-generated method stub
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
View viewlayout = inflater.inflate(R.layout.layout_fullscreen_view,container,false);
ImageView imageview=(ImageView) viewlayout.findViewById(R.id.imgDisplay);
imageview.setImageResource(images1[position]);
((ViewPager) container.addView(viewlayout);
return viewlayout;
}

最佳答案

试试这个。

In Your code 

((ViewPager) container.addView(viewlayout,0);

在您的代码的上面一行中,您错过了“)”。这就是它给出错误的原因。试试这个,然后它就会被修复。

((ViewPager) container).addView(viewlayout,0);

关于android - 错误显示在 viewpager 添加 View 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20040556/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com