Reputation: 11782
i am using following code to attach an image placed in my asset Folder
ArrayAdapter<CharSequence> adapter = new CustomArrayAdapterForCurrencies(this, currenciesDataSource.keys);
paidIn.setAdapter(adapter);
viewHolder.flag = (ImageView) view.findViewById(R.id.UICurrencyCurrencyFlag);
String filename = "Images/Currencies/" + keys[position] + ".png";
try {
InputStream bitmap= context.getResources().getAssets().open(filename);
Bitmap bit=BitmapFactory.decodeStream(bitmap);
viewHolder.flag.setImageBitmap(bit);
} catch (IOException e1) {
e1.printStackTrace();
}
But when i click on Spinner following this happens, If i click on let us say , INR, The indian flag shows up just like above, but i want all the flags to be shown in this screen too.
Please tell me what is the problem Best Regards
Upvotes: 2
Views: 661
Reputation: 14058
If PaidIn is a spinner ,then you must have set a DropDownViewResource layout file for it using setDropDownViewResource()
. Use a custom layout file with an imageview and textview as your drop down resource, then you will be able to shown Indian and other flag images too... For example:
Spinner spin = (Spinner) findViewById(R.id.spinner);
spin.setOnItemSelectedListener(this);
ArrayAdapter aa = new ArrayAdapter(
this,
android.R.layout.simple_spinner_item,
items);
aa.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(aa);
Upvotes: 1