in my spinner i am trying to attach an image and a text View,
Following is my layout xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/UICurrencyCurrencyFlag"
android:layout_height="20dp"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/cross_btn" />
<TextView
android:id="@+id/UICurrencyCurrencyName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:textStyle="bold"
android:layout_toRightOf="@+id/UICurrencyCurrencyFlag"
android:text="TextView" />
</RelativeLayout>
Following is the constructor i am using for my Custom Array Adapter
public class CustomArrayAdapterForCurrencies extends ArrayAdapter<CharSequence>
{
private final Activity context;
public final CharSequence[] keys;
public CustomArrayAdapterForCurrencies(Activity context, CharSequence[] keys)
{
super(context, R.layout.ui_currency_layout,keys);
this.context = context;
this.keys = keys;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = null;
LayoutInflater inflator = context.getLayoutInflater();
view = inflator.inflate(R.layout.ui_currency_layout, null);
final ViewHolder viewHolder = new ViewHolder();
When my activity starts, spinner does show image and text but when i try to select spinner it gives error that Adapter need resouce id for the text view
How can i resolve this issue,
Best Regards
Change your
superstatement tosuper(context, R.layout.ui_currency_layout, R.id.YourTextId , keys);