android findViewById 空指针报错 怎么解决
publicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);//fin...
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// final LinearLayout choose = (LinearLayout) getLayoutInflater().inflate(R.layout.illustrate_image, null);
// final Gallery myGallery = (Gallery) choose.findViewById(R.id.gallery111);
setContentView(R.layout.illustrate_image);
Gallery myGallery = (Gallery) findViewById(R.id.gallery111);
ImageAdapter adapter = new ImageAdapter(this);
(R.styleable.Gallery_android_galleryItemBackground, 0));
myGallery.setAdapter(adapter);
}
名字没写错,gallery111也的确是在这个布局文件里,clean过了,都没有用,求大神提示! 展开
super.onCreate(savedInstanceState);
// final LinearLayout choose = (LinearLayout) getLayoutInflater().inflate(R.layout.illustrate_image, null);
// final Gallery myGallery = (Gallery) choose.findViewById(R.id.gallery111);
setContentView(R.layout.illustrate_image);
Gallery myGallery = (Gallery) findViewById(R.id.gallery111);
ImageAdapter adapter = new ImageAdapter(this);
(R.styleable.Gallery_android_galleryItemBackground, 0));
myGallery.setAdapter(adapter);
}
名字没写错,gallery111也的确是在这个布局文件里,clean过了,都没有用,求大神提示! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询