我有以下代码显示一个图像与字母,
- public class MainActivity extends Activity
- {
- private String[] capital_letters,small_letters;
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- this.requestWindowFeature(Window.FEATURE_NO_TITLE);
- this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_main);
- }
- @Override
- protected void onStart()
- {
- super.onStart();
- try
- {
- capital_letters = getApplicationContext().getResources().getStringArray( R.array.capital_letters );
- small_letters = getApplicationContext().getResources().getStringArray( R.array.small_letters );
- MyAdapter adapter = new MyAdapter ( MainActivity.this,capital_letters,small_letters );
- ListView list = ( ListView ) findViewById( R.id.list );
- list.setAdapter( adapter );
- list.setOnItemClickListener( new AdapterView.OnItemClickListener()
- {
- @Override
- public void onItemClick(AdapterView<?> arg0,View arg1,int position,long id )
- {
- Intent intent = new Intent ( MainActivity.this,LetterActivity.class );
- intent.putExtra( "position",position );
- intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(intent);
- overridePendingTransition( 0,0 );
- }
- });
- }
- catch ( Exception e ){e.printStackTrace();}
- }
- }
解决方法
看看
this question and all its answers,谈到Android上的性能优化很多.