Using java Syntax Highlighting
- public class GalleryExample extends Activity AdapterView.OnItemSelectedListener{
- ImageView i;
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.main);
- /* Find the gallery defined in the main.xml
- * Apply a new (custom) ImageAdapter to it. */
- Gallery g = (Gallery) findViewById(R.id.image1);
- g.setAdapter(new ImageAdapter(this));
- g.setOnItemSelectedListener(this);
- }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
and in getView method
Using java Syntax Highlighting
- public View getView(int position, View convertView, ViewGroup parent) {
- ImageView i = new ImageView(this.myContext);
- i.setImageResource(this.myImageIds[position]);
- /* Image should be scaled as width/height are set. */
- i.setScaleType(ImageView.ScaleType.FIT_XY);
- /* Set the Width/Height of the ImageView. */
- i.setLayoutParams(new Gallery.LayoutParams(150, 150));
- i.setBackground(android.R.drawable.picture_frame);
- return i;
- }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
i want change background of selected image in onItemSelected method
i used
Using java Syntax Highlighting
- public void onItemSelected(AdapterView parent, View v, int position, long id) {
- i.setBackground(android.R.drawable.panel_picture_frame_bg_pressed_blue );
- invalidate();
- }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
but don't change selected image background,change last two images background......how to change selected image background??

