Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Gallery View - How to set resource?
    primarykey
    data
    text
    <p>I am new to Java programming / Android development - but I have been working through a few examples and have been trying to build a "mix-and-match" app with 3 scrolling galley views.</p> <p>I have created the relative layout with 3 gallery views, and have defined 3 arrays to contain a list of images.</p> <p>My problem is that I can't seem to get the ImageAdapter to set the correct image resource for each gallery view (it duplicates the same images across all 3 galleries).</p> <p>If I can just post the relevant sections of code:</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); Gallery gTop = (Gallery) findViewById(R.id.gallery_top); Gallery gMid = (Gallery) findViewById(R.id.gallery_mid); Gallery gEnd = (Gallery) findViewById(R.id.gallery_end); gTop.setAdapter(new ImageAdapter(this)); gMid.setAdapter(new ImageAdapter(this)); gEnd.setAdapter(new ImageAdapter(this)); } </code></pre> <p>Then another class sets the resources (hardcoded):</p> <pre><code> public View getView(int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(mContext); i.setImageResource(mEndThumbIds[position]); i.setAdjustViewBounds(true); i.setLayoutParams(new Gallery.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) ); return i; } </code></pre> <p>How can I remove this hardcoded link and check to see what object is calling getView and set the image resources accordingly?</p> <p>Thanks, Alex</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload