Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap Long Text #91

Open
jasminapolinar8 opened this issue Dec 12, 2017 · 0 comments
Open

Wrap Long Text #91

jasminapolinar8 opened this issue Dec 12, 2017 · 0 comments

Comments

@jasminapolinar8
Copy link

jasminapolinar8 commented Dec 12, 2017

I tried creating a multiline_spinner_dropdown_item.xml
And it contains:

<?xml version="1.0" encoding="utf-8"?>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:singleLine="false"/>

Then I called it here:
EloadFragment.java

@Override
    public void onActivityCreated(final Bundle savedInstanceState){
        super.onActivityCreated(savedInstanceState);

        final MaterialBetterSpinner spinnerDropdown1 = myView.findViewById(R.id.material_spinner);
        ArrayAdapter adapter1 = ArrayAdapter.createFromResource(myView.getContext(), R.array.spinner_smart, R.layout.multiline_spinner_dropdown_item);
        spinnerDropdown1.setAdapter(adapter1);
        spinnerDropdown1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(myView.getContext(),"Selected: "+adapterView.getItemAtPosition(i),Toast.LENGTH_SHORT).show();
                spinnerDropdown1.clearFocus();
            }
        });
    }

Sample output of the spinner: (The first item didn't wrap the long text)
imageedit_4_7397778429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant