首先,我首先把这交给了甲状腺 go集团,但是,它的温和和和我不敢肯定,要在这里展示这样希望的人,需要多长时间才能帮助。
I created a simple app with a ListView following the ListActivity examples I found on the net.
The app has 2 activities with the first having a button to create the second. When i hit the close button on the second activity I would like it to release its memory (or at least allow it to be garbage collected). Currently it will never release.
I must be doing something wrong here because the MyListActivity never gets released. Can anyone tell me if I am doing something wrong with the way my activities are created/destroyed? or if my usage of the ListView is wrong?
感谢。
Screen Shot of Eclipse MAT showing the list activity never releasing memory - www.mediafire.com/?qr6ga0k
public class MyListActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listlayout);
ListAdapter ada = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, GENRES);
setListAdapter(ada);
}
@Override
public void onDestroy()
{
super.onDestroy();
System.gc();
}
public void ClickHandler(View target)
{
switch (target.getId())
{
case R.id.LL_Btn1:
finish();
break;
}
}
private static final String[] GENRES = new String[] {
"Action", "Adventure", "Animation", "Children", "Comedy", "Documentary", "Drama",
"Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller"
};}
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void ClickHandler(View target)
{
switch (target.getId())
{
case R.id.M_Button01:
Intent intent = new Intent();
intent.setClassName(MyListActivity.class.getPackage().getName(), MyListActivity.class.getName());
startActivity(intent);
break;
}
}}