Reputation: 11
i have a custom gallery in android and i have i previewwindow for the items that are in the gallery.
as soon as i switch the item to be displayed in the previewindow the order around the image dissapears.
here is the on create for the activity:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display d = wm.getDefaultDisplay();
int width = d.getWidth();
// Setup window
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.wallpaperpicker);
setupTopMenu(1, 0);
if (width < 480) {
findViewById(R.id.previewframe).setVisibility(View.GONE);
}
// Init view content
Context context = getBaseContext();
Resources res = context.getResources();
gallery = (Gallery) findViewById(R.id.WallpaperBrowser);
m_bitmap = BitmapFactory.decodeResource(res,(width >= 480) ? m_previews[0] : m_bitmaps[0]);
currentResource = 0;
m_adapter = new BitmapAdapter(this, width);
m_adapter.addBitmap(m_bitmap);
for (int i = 1; i < m_bitmaps.length; ++i)
{
m_adapter.addBitmap(BitmapFactory.decodeResource(res,(width >= 480) ? m_previews[i] : m_bitmaps[i]));
}
gallery.setAdapter(m_adapter);
// Setup listeners and media scanner
gallery.setOnItemSelectedListener(this);
Button set = (Button) findViewById(R.id.SetButton);
set.setOnClickListener(this);
// Set middle item (rounded down) in gallery as selected item
gallery.setSelection(2);// m_adapter.getCount() >> 1, true);
gallery.setCallbackDuringFling(false); // Change to false if image
// shouldn't switch while
// flinging
gallery.onFling(null, null, 8000, 0);
}
and the callback when an item in the gallery is selected
Upvotes: 0
Views: 157
Reputation: 11
Might as well post an answer, seems that I didn't call:
((BaseAdapter)parent.getAdapter()).notifyDataSetChanged();
in my onItemSelected
function.
Upvotes: 1