Spinner with long text not working fine

雨燕双飞 提交于 2019-12-05 09:40:06

For my problem I found this solution :

Spinner language = (Spinner) findViewById(com.Orange.R.id.current_language_text);

ArrayAdapter adapter = new ArrayAdapter(this,
                com.Orange.R.layout.my_spinner_textview, languages);
adapter.setDropDownViewResource(com.Orange.R.layout.multiline_spinner_dropdown_item);
language.setAdapter(adapter);

where languages is a String[] and my_spinner_textview.xml is :

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/textview_spinner"
    style="?android:attr/spinnerItemStyle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textColor="@drawable/textorange_selected" 
    android:paddingLeft="5dp"
    android:singleLine="true"
    android:ellipsize="end"
 />

simply I did with custom text view like:

ArrayAdapter myAdapter = new ArrayAdapter(context, R.layout.text_view, reasonTypesList);
myAdapter.setDropDownViewResource(R.layout.text_view);
mySpinner.setAdapter(myAdapter);

and here is the text_view layout:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/spinnerTextView"
    style="?android:attr/spinnerItemStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="@dimen/padding"
    android:text="Custom Text with multi lines" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!