I am working on an Android project that follows the tutorial at this youtube link: https://www.youtube.com/watch?v=YCHNAi9kJI4 . It is an animated listView deletion.
I have an image setup within part of the opaque_text_view.xml file:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/image_text_vew_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/tv_background_with_divider"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:drawableLeft="@drawable/ic_launcher" <--------------------------
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
/>
Which comes up perfectly, but, I would like to change the image dynamically so that it will adjust with gmail-like icons that reflect the letters and colors of the mail itself. I already have the code for setting an image to look like the Gmail client which I obtained here: Colored boxed with letters a la Gmail .
The issue I am having is that the code to adjust the opaque_text_view.xml is only found in an adapter:
public class ListViewRemovalAnimation extends Activity {
StableArrayAdapter mAdapter;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_view_deletion);
mBackgroundContainer = (BackgroundContainer) findViewById(R.id.listViewBackground);
//Set the adapter here
--> mAdapter = new StableArrayAdapter(this,R.layout.opaque_text_view, list, mTouchListener);** <--
mListView.setAdapter(mAdapter);
}
The StableArrayAdapter is its own class and is defined like this:
public class StableArrayAdapter extends ArrayAdapter<String> {
...
}
I basically have to edit the picture from within that StableArrayAdapter, but as it does not extend to an activity, I can't find a way to do it. I tried working in the code from this How to programmatically set drawableLeft on Android button? link, but same problem.
To phrase it another way, how do I change the image in the opaque_text_view (drawableleft) to update it to this:
final LetterTileProvider tileProvider = new LetterTileProvider(this);
final Bitmap letterTile = tileProvider.getLetterTile("name", "key", tileSize, tileSize);
//SET BITMAP IMAGE HERE!!!
without the benefit of an activity. Anyone have any recommendations?