產品圖的應用程序的位置:http://imgur.com/6A92Yl6Android圖庫只顯示三張圖片
所以我已經設置了在一點擊中的畫廊,用戶可以選擇從視角的圖片,然後看到的圖片及其相應的爲它烤麪包。
問題是,只有三個圖像彈出。我不知道爲什麼,也沒有限制畫廊的變數,所以我不知所措。
我的主:
public class MainActivity<View> extends Activity
{
ImageView selectedImage;
private Integer[] mImageIds = {
R.drawable.image1,
R.drawable.image2,
R.drawable.image3,
R.drawable.image4,
R.drawable.image5,
R.drawable.image6,
R.drawable.image7,
R.drawable.image8,
R.drawable.image9,
R.drawable.image10
};
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Gallery gallery = (Gallery) findViewById(R.id.gallery1);
selectedImage=(ImageView)findViewById(R.id.imageView1);
gallery.setSpacing(1);
gallery.setAdapter(new GalleryImageAdapter(this));
gallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(MainActivity.this, "THIS TEXT SHOULD NEVER SHOW = " + position, Toast.LENGTH_SHORT).show();
// show the selected Image
selectedImage.setImageResource(mImageIds[position]);
}
@Override
public void onItemClick(AdapterView<?> parent, android.view.View v, int position, long id) {
Toast.makeText(MainActivity.this, "Picture Number: " + position, Toast.LENGTH_SHORT).show();
// show the selected Image
selectedImage.setImageResource(mImageIds[position]);
}
});
}
}
我的XML:
<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"
android:orientation="vertical" >
<Gallery
android:id="@+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="350dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="100dp"
android:layout_weight="0.13"
android:src="@drawable/image1" />
</LinearLayout>
你沒有使用你的清單與適配器來填充它。顯示適配器的實現。 –