I get an error (layer exceeds max dimensions) whenever I just instert a large String onto a textview and then add it as an element of a listview. Here is my list_item_simple_black_tv.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tv"
android:textColor="@android:color/white"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:textSize="30dp"
android:singleLine="false"
android:scrollHorizontally="false"
android:ellipsize="end"
android:minLines="1"
android:maxLength="100"
/>
I then try to add it to a list on a layout that looks like this:
The code that I use in order to populate the list is:
String[] specialOffers = shop.getSpecialOffers().split("~");//this is the means of grabbing data. I have tested it and its valid
ListView specialOffersListView = (ListView) findViewById(R.id.specialOffersList);
ArrayAdapter<String> specialOffersListViewAdapter = new ArrayAdapter<String>(getApplicationContext(),R.layout.list_item_simple_black_tv, specialOffers);
specialOffersListView.setAdapter(specialOffersListViewAdapter);
specialOffersListView.setClickable(false);
specialOffersListViewAdapter.notifyDataSetChanged();
After further investigation from myself I concluded that whenever I add an array that contains a large string the app may crash because the text goes "too much to the right" and does not automatically turn multiline in order to fit the list.
Aucun commentaire:
Enregistrer un commentaire