Android 我的代码有什么问题(片段库)
我是安卓新手。。 有人能告诉我我的代码有什么问题吗?我想把画廊变成碎片。当我在设备上安装apk文件时,程序可以运行,但在该片段中,我看到的是白色屏幕而不是多媒体资料。请帮助我: 那是我的片段类 这就是我对这个片段的布局Android 我的代码有什么问题(片段库),android,android-fragments,android-gallery,Android,Android Fragments,Android Gallery,我是安卓新手。。 有人能告诉我我的代码有什么问题吗?我想把画廊变成碎片。当我在设备上安装apk文件时,程序可以运行,但在该片段中,我看到的是白色屏幕而不是多媒体资料。请帮助我: 那是我的片段类 这就是我对这个片段的布局 Getview方法有问题吗 @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { hol
Getview方法有问题吗
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
holder = new ViewHolder();
imageView = new ImageView(this.context);
imageView.setPadding(3, 3, 3, 3);
convertView = imageView;
holder.imageView = imageView;
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.imageView.setImageDrawable(plotsImages.get(position));
holder.imageView.setScaleType(ImageView.ScaleType.FIT_XY);
holder.imageView.setLayoutParams(new Gallery.LayoutParams(150, 90));
return imageView;
}
private static class ViewHolder {
ImageView imageView;
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="{relativePackage}.${activityClass}"
android:orientation="vertical" >
<Gallery
android:id="@+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/image1"
android:layout_width="215dp"
android:layout_height="315dp"
android:layout_gravity="center_horizontal"
android:background="#cfcfcf"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:src="@drawable/car1"
android:contentDescription="@null" />
</LinearLayout>
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
holder = new ViewHolder();
imageView = new ImageView(this.context);
imageView.setPadding(3, 3, 3, 3);
convertView = imageView;
holder.imageView = imageView;
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.imageView.setImageDrawable(plotsImages.get(position));
holder.imageView.setScaleType(ImageView.ScaleType.FIT_XY);
holder.imageView.setLayoutParams(new Gallery.LayoutParams(150, 90));
return imageView;
}
private static class ViewHolder {
ImageView imageView;
}