Memory issue with items in BaseAdapter
pI have a codeListView/code where every row view is inflated from this xml
layout (by activity layout inflater):/p precodelt;?xml version=1.0
encoding=utf-8?gt; lt;LinearLayout
xmlns:android=http://schemas.android.com/apk/res/android
android:baselineAligned=false android:layout_width=fill_parent
android:layout_height=wrap_content
android:background=@drawable/topic_list_item_selector
android:orientation=horizontal
android:paddingLeft=@dimen/list_item_padding_horizontal_big
android:paddingBottom=@dimen/list_item_padding_vertical_big
android:paddingTop=@dimen/list_item_padding_vertical_big gt;
lt;LinearLayout android:id=@+id/topics_list_edit_row_label_color
android:layout_width=@dimen/label_rect_edge_size
android:layout_height=@dimen/label_rect_edge_size
android:orientation=vertical gt; lt;TextView
android:id=@+id/topics_list_edit_row_label_text
android:layout_width=wrap_content android:layout_height=wrap_content
android:layout_gravity=center android:textColor=#ffffff
android:textSize=@dimen/label_text_size /gt; lt;/LinearLayoutgt;
lt;LinearLayout android:id=@+id/topics_list_edit_row_text
android:layout_width=0dp android:layout_height=wrap_content
android:layout_gravity=center_vertical android:layout_weight=1
android:orientation=vertical gt; lt;TextView
android:id=@+id/topics_list_edit_row_text_title style=@style/DefaultText
android:layout_width=fill_parent android:layout_height=wrap_content
android:text=title /gt; lt;LinearLayout android:layout_width=fill_parent
android:layout_height=wrap_content android:orientation=horizontal gt;
lt;TextView android:id=@+id/topics_list_edit_row_text_detail_section
style=@style/DetailText android:layout_width=0dp
android:layout_height=wrap_content android:layout_weight=1 android:text=2
sections android:textColor=#818181 /gt; lt;TextView
android:id=@+id/topics_list_edit_row_text_detail_point
style=@style/DetailText android:layout_width=0dp
android:layout_height=wrap_content android:layout_weight=1 android:text=85
points android:textColor=#818181 /gt; lt;/LinearLayoutgt;
lt;/LinearLayoutgt; lt;/LinearLayoutgt; /code/pre pWhen I return this view
in my Adapter via codegetView()/code, everything works normally./p pBut
when I change some text in codeTextView/code via codesetText()/code in
codegetView()/code, my app consumes about 1mb more with every screen
rotation:/p precodepublic class TopicListAdapter extends BaseAdapter{ ...
public View getView(int position, View convertView, ViewGroup parent) {
View rowView; if (convertView == null) { LayoutInflater inflater =
(LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView =
inflater.inflate(R.layout.topics_list_edit_row, parent, false); ...
Typeface myTypeface = Typeface.createFromAsset(context.getAssets(),
Roboto-Thin.ttf); //Added TextView labelT = (TextView)
rowView.findViewById(R.id.topics_list_edit_row_label_text);
labelT.setTypeface(myTypeface); //Added labelT.setText(A); //!!!! when I
delete this line everything works normally !!!! ... } ... } } /code/pre pI
think maybe my activity context remains alive after every screen rotation
but if this is the case then how does it happen and how do I avoid it?/p
No comments:
Post a Comment