Hello I have a gallery with 2 images in it. I want each time i change the image a textview in my layout to change its name. In my code it happens only the first time and remains that way.
public class BrowseActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.browse_activity_layout);
Gallery gallery = (Gallery) findViewById(R.id.browseActivityGallery);
gallery.setAdapter(new ImageAdapter(this));
gallery.setSpacing(0);
}
public class ImageAdapter extends BaseAdapter {
int mGalleryItemBackground;
private Context mContext;
private Integer[] mImageIds = {
R.drawable.building_a,
R.drawable.building_b,
};
public ImageAdapter(Context c) {
mContext = c;
TypedArray attr = mContext.obtainStyledAttributes(R.styleable.browseActivityGalleryStylable);
attr.recycle();
}
public int getCount() {
return mImageIds.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
TextView browseActivityTitleTextView = (TextView)findViewById(R.id.browseActivityTitleTextView);
if(position == 0){
browseActivityTitleTextView.setText(" Α'");
}
if(position == 1){
browseActivityTitleTextView.setText(" Β'");
}
ImageView imageView = new ImageView(mContext);
imageView.setImageResource(mImageIds[position]);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
return imageView;
}
}
}
When i swipe the gallery it changes to B' as it should but when i swipe back it stays B' Anyone knows how to fix this?