-1

我有一个包含两个活动的程序。我从第一个活动转到第二个活动。然后按返回键,程序有延迟并显示白屏。如何消除延迟?当我点击我的按钮时,在第一个活动中执行此操作

myHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    Animation vanish2 =AnimationUtils.loadAnimation(MainActivity.this,R.anim.out_to_right);
                    findViewById(R.id.imageView1).startAnimation(vanish2);
                    findViewById(R.id.textView1).startAnimation(vanish2);
                    vanish2.setAnimationListener(new AnimationListener() {

                        @Override
                        public void onAnimationStart(Animation arg0) {


                        }

                        @Override
                        public void onAnimationRepeat(Animation arg0) {
                            //startActivity(new Intent(MainActivity.this,S1.class));

                        }

                        @Override
                        public void onAnimationEnd(Animation arg0) {
                            t1.setVisibility(View.INVISIBLE);
                            i1.setVisibility(View.INVISIBLE);
                            startActivity(new Intent(MainActivity.this,S1.class));

                            //overridePendingTransition(R.anim.fadeout, R.anim.fadein);   
                            //overridePendingTransition(R.anim.push_down_in, R.anim.push_down_out);

                        }
                    });
                }
            }, 400);

第二个活动什么都没有,我只想按后退按钮并退出第二个活动

这是我的第一个活动。顺便说一句,我是 android 的初学者

public class MainActivity extends Activity {

private ViewFlipper viewFlipper;
private float lastX;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //getWindow().setFlags(WindowManager.LayoutParams.FLAG_DITHER, WindowManager.LayoutParams.FLAG_DITHER);
    /*requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);*/  
    setContentView(R.layout.activity_main);
    EjadeText();
    SabteDataBase();
    viewFlipper = (ViewFlipper) findViewById(R.id.view_flipper);
    final ImageView i1 = (ImageView) findViewById(R.id.imageView1);
    final ImageView i2 = (ImageView) findViewById(R.id.imageView2);
    final ImageView i3 = (ImageView) findViewById(R.id.imageView3);
    final ImageView i4 = (ImageView) findViewById(R.id.imageView4);
    final ImageView i5 = (ImageView) findViewById(R.id.imageView5);
    final TextView t1 = (TextView) findViewById(R.id.textView1);
    final TextView t2 = (TextView) findViewById(R.id.textView2);
    final TextView t3 = (TextView) findViewById(R.id.textView3);
    final TextView t4 = (TextView) findViewById(R.id.textView4);
    final TextView t5 = (TextView) findViewById(R.id.textView5);
    int a = getResources().getConfiguration().orientation;

    if(a!=2)
    {
    i1.setOnClickListener(new OnClickListener() {




        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            //viewFlipper.setOutAnimation(MainActivity.this, R.anim.out_to_right);
            //viewFlipper.showNext();
            Animation vanish =AnimationUtils.loadAnimation(MainActivity.this,R.anim.out_to_right);
            findViewById(R.id.imageView5).startAnimation(vanish);
            findViewById(R.id.textView5).startAnimation(vanish);
            vanish.setAnimationListener(new AnimationListener() {

                @Override
                public void onAnimationStart(Animation arg0) {


                }

                @Override
                public void onAnimationRepeat(Animation arg0) {
                    //startActivity(new Intent(MainActivity.this,S1.class));

                }

                @Override
                public void onAnimationEnd(Animation arg0) {
                    i5.setVisibility(View.INVISIBLE);
                    t5.setVisibility(View.INVISIBLE);

                }
            });

            Handler myHandler = new Handler();
            myHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    Animation vanish2 =AnimationUtils.loadAnimation(MainActivity.this,R.anim.out_to_right);
                    findViewById(R.id.imageView4).startAnimation(vanish2);
                    findViewById(R.id.textView4).startAnimation(vanish2);
                    vanish2.setAnimationListener(new AnimationListener() {

                        @Override
                        public void onAnimationStart(Animation arg0) {


                        }

                        @Override
                        public void onAnimationRepeat(Animation arg0) {
                            //startActivity(new Intent(MainActivity.this,S1.class));

                        }

                        @Override
                        public void onAnimationEnd(Animation arg0) {
                            i4.setVisibility(View.INVISIBLE);
                            t4.setVisibility(View.INVISIBLE);

                        }
                    });
                }
            }, 100);

            myHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    Animation vanish2 =AnimationUtils.loadAnimation(MainActivity.this,R.anim.out_to_right);
                    findViewById(R.id.imageView3).startAnimation(vanish2);
                    findViewById(R.id.textView3).startAnimation(vanish2);
                    vanish2.setAnimationListener(new AnimationListener() {

                        @Override
                        public void onAnimationStart(Animation arg0) {


                        }

                        @Override
                        public void onAnimationRepeat(Animation arg0) {
                            //startActivity(new Intent(MainActivity.this,S1.class));

                        }

                        @Override
                        public void onAnimationEnd(Animation arg0) {
                            i3.setVisibility(View.INVISIBLE);
                            t3.setVisibility(View.INVISIBLE);

                        }
                    });
                }
            }, 200);
            myHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    Animation vanish2 =AnimationUtils.loadAnimation(MainActivity.this,R.anim.out_to_right);
                    findViewById(R.id.imageView2).startAnimation(vanish2);
                    findViewById(R.id.textView2).startAnimation(vanish2);
                    vanish2.setAnimationListener(new AnimationListener() {

                        @Override
                        public void onAnimationStart(Animation arg0) {


                        }

                        @Override
                        public void onAnimationRepeat(Animation arg0) {
                            //startActivity(new Intent(MainActivity.this,S1.class));

                        }

                        @Override
                        public void onAnimationEnd(Animation arg0) {
                            i2.setVisibility(View.INVISIBLE);
                            t2.setVisibility(View.INVISIBLE);

                        }
                    });
                }
            }, 300);
            myHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    Animation vanish2 =AnimationUtils.loadAnimation(MainActivity.this,R.anim.out_to_right);
                    findViewById(R.id.imageView1).startAnimation(vanish2);
                    findViewById(R.id.textView1).startAnimation(vanish2);
                    vanish2.setAnimationListener(new AnimationListener() {

                        @Override
                        public void onAnimationStart(Animation arg0) {


                        }

                        @Override
                        public void onAnimationRepeat(Animation arg0) {
                            //startActivity(new Intent(MainActivity.this,S1.class));

                        }

                        @Override
                        public void onAnimationEnd(Animation arg0) {
                            t1.setVisibility(View.INVISIBLE);
                            i1.setVisibility(View.INVISIBLE);
                            Intent i = new Intent (MainActivity.this,S1.class);
                            startActivity(i);
                            //startActivity(new Intent(MainActivity.this,S1.class));

                            //overridePendingTransition(R.anim.fadeout, R.anim.fadein);   
                            //overridePendingTransition(R.anim.push_down_in, R.anim.push_down_out);

                        }
                    });
                }
            }, 400);


        }

    });



@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.

    //getMenuInflater().inflate(R.menu.main, menu);
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.layout.menu, menu);
    return true;
}

public boolean onOptionsItemSelected(MenuItem item)
{

    switch (item.getItemId())
    {
    case R.id.menu_exit:
        // Single menu item is selected do something
        // Ex: launching new activity/screen or show alert message
        finish();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}    


////////baraye neveshtane file bayad dar manifest e barname ejaze dad khte 4
public void EjadeText()
{
    File sdcard = Environment.getExternalStorageDirectory();
    File myFile = new File(sdcard,"Mas.txt"); //sabt file to sdcard

    /////////eijade file txt Masirha
    try
    {
        String[] valueS1 = new String[] { "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392",
                "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392", "1  -  2  -  3  -  عباس آباد  -  11/02/1392", "4  -  5  -  6  -  سعادت آباد  -  22/03/1392"};

        myFile.createNewFile();
        FileOutputStream fOut = new FileOutputStream(myFile);
        OutputStreamWriter myOutWriter =new OutputStreamWriter(fOut);


        for (int i=0; i<valueS1.length; i++)
        {
            myOutWriter.append(valueS1[i]);
            myOutWriter.append(";\n");
        }

        myOutWriter.close();
        fOut.close();
    }
    catch(IOException e)
    {

    }

    /////////eijade file txt Masirha ta inja*/



    /////////eijade file txt Moshtari
    File myFile1 = new File(sdcard,"Mosh.txt"); //sabt file to sdcard
    try
    {
        String[] valueS1 = new String[] { "1 - علی احمدی - خ شيخ مفيد ک سعدي - 7896541;10,000,000;20,000,000;0;2000;علی احمدی;1;",
                "2 - علی احمدپور - خ شيخ مفيد ک سعدي - 7896541;1,000;2;0;2;علی احمدپور;2;",
                "3 - علی احمدپور - خ شيخ مفيد ک سعدي - 7896541;10787800;20,45500;0;20450;علی احمدپور;3;",
                "4 - اصغر اصغری - خ شيخ صدوق ک علامه - 9875236;123456;654321;1478523;0;اصغر اصغری;4;",
                "5 - علی احمدی - خ شيخ مفيد ک سعدي - 7896541;10,000,000;20,000,000;0;2000;علی احمدی;5;",
                "6 - اصغر اصغری - خ شيخ صدوق ک علامه - 9875236;123456;654321;1478523;0;اصغر اصغری;6;"};
        myFile1.createNewFile();
        FileOutputStream fOut = new FileOutputStream(myFile1);
        OutputStreamWriter myOutWriter =new OutputStreamWriter(fOut);
        for (int i=0; i<valueS1.length; i++)
        {
            myOutWriter.append(valueS1[i]);
            myOutWriter.append(";\n");
        }
        myOutWriter.close();
        fOut.close();
    }
    catch(IOException e)
    {

    }
    /////////eijade file txt Moshtari ta inja */



    //////// Ejade File txt Kala 
    File myFile2 = new File(sdcard,"Kala.txt"); //sabt file to sdcard
    try
    {
        String[] valueS1 = new String[] { "1 - Keyk - keyke yazdi - duneyee - basteyee - 5000 - 50;50;Keyk;1;","2 - Tanagholat - pastil - basteyee - kilooye - 20000 - 4000;4000;Tanagholat;2;",
                "3 - Keyk - keyke yazdi - duneyee - basteyee - 5000 - 50;50;Keyk;3;","4 - Tanagholat - pastil - basteyee - kilooye - 20000 - 4000;4000;Tanagholat;4;"};
        myFile2.createNewFile();
        FileOutputStream fOut = new FileOutputStream(myFile2);
        OutputStreamWriter myOutWriter =new OutputStreamWriter(fOut);
        for (int i=0; i<valueS1.length; i++)
        {
            myOutWriter.append(valueS1[i]);
            myOutWriter.append(";\n");
        }
        myOutWriter.close();
        fOut.close();
    }
    catch(IOException e)
    {

    }


    File myFile3 = new File(sdcard,"KalaGorooh.txt"); //sabt file to sdcard
    try
    {
        String[] valueS1 = new String[] { "Keyk;","Tanagholat;"};
        myFile3.createNewFile();
        FileOutputStream fOut1 = new FileOutputStream(myFile3);
        OutputStreamWriter myOutWriter1 =new OutputStreamWriter(fOut1);
        for (int i=0; i<valueS1.length; i++)
        {
            myOutWriter1.append(valueS1[i]);
            myOutWriter1.append("\n");
        }
        myOutWriter1.close();
        fOut1.close();
    }
    catch(IOException e)
    {

    }
    ////// Ejade File txt Kala tainja*/ 

}

public void SabteDataBase()
{
    final android.database.sqlite.SQLiteDatabase  myDB= this.openOrCreateDatabase("DB_Bazaryab", MODE_PRIVATE, null);
    /////////  Ejade DB va Table 
    ////////   khundane file text baraye masirha va Ejade Table
    try 
    {

        File sdcard = Environment.getExternalStorageDirectory();
        File file = new File(sdcard,"Mas.txt");
        StringBuilder text = new StringBuilder();
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line;
        while ((line = br.readLine()) != null) {
            text.append(line);
        }
        String TableName = "Tbl_Masir";
        String[] valueS = text.toString().split(";");
        myDB.execSQL("DROP TABLE IF EXISTS Tbl_Masir");
     // "IF NOT EXIT" ro baraye test bardashtam
        myDB.execSQL("CREATE TABLE Tbl_Masir (id int, Address VARCHAR);");
        for (int i=0; i<valueS.length; i++)
        {

        myDB.execSQL("INSERT INTO "
                 + TableName
                 + " (id, Address)"
                 + " VALUES ("+ Integer.toString(i)+",'"+valueS[i] + "');");
        }

    }
    catch(IOException e)
    {

    }
    ////////khundane file text baraye masirha va Ejade Table ta inja */



     ////////khundane file text baraye Moshtari va Ejade Table
    try 
    {
        File sdcard = Environment.getExternalStorageDirectory();
        File file = new File(sdcard,"Mosh.txt");
        StringBuilder text = new StringBuilder();
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line;
        while ((line = br.readLine()) != null) {
            text.append(line);
        }

        myDB.execSQL("DROP TABLE IF EXISTS Tbl_Moshtari");
        String[] valueS = text.toString().split(";");
     // "IF NOT EXIT" ro baraye test bardashtam
        myDB.execSQL("CREATE TABLE Tbl_Moshtari (id int, Info VARCHAR,Et_Naghd VARCHAR,Et_Chek VARCHAR,Mande_Bedehi VARCHAR, Cheke_Bargashti VARCHAR,Name_Moshtari VARCHAR,Code_Moshtari VARCHAR);");
        int k=0;
        for (int i=0; i<valueS.length; i=i+8)
        {
        myDB.execSQL("INSERT INTO Tbl_Moshtari (id, Info, Et_Naghd, Et_Chek ,Mande_Bedehi ,Cheke_Bargashti , Name_Moshtari, Code_Moshtari)  VALUES ("+ Integer.toString(k)+",'"+valueS[i] + "','"+ valueS[i+1]+"','"+valueS[i+2] +"','" +valueS[i+3]+"','"+valueS[i+4] +"','"+valueS[i+5] +"','"+valueS[i+6] +"');");
        k++;
        }
    }
    catch(IOException e)
    {

    } 


    ////////khundane file text baraye Moshtari va Ejade Table  ta inja*/ 

     ////////khundane file text baraye Kala va Ejade Table
    try 
    {

        File sdcard = Environment.getExternalStorageDirectory();
        File file = new File(sdcard,"Kala.txt");
        StringBuilder text = new StringBuilder();
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line;
        while ((line = br.readLine()) != null) {
            text.append(line);
        }
        String TableName = "Tbl_Kala";
        String[] valueS = text.toString().split(";");
        myDB.execSQL("DROP TABLE IF EXISTS Tbl_Kala");
     // "IF NOT EXIT" ro baraye test bardashtam
        myDB.execSQL("CREATE TABLE Tbl_Kala (id int, Kalaha VARCHAR, Gh_Vahed VARCHAR, Name_Gorooh VARCHAR, Code_Kala VARCHAR);");
        for (int i=0; i<valueS.length; i = i+5)
        {

        myDB.execSQL("INSERT INTO "
                 + TableName
                 + " (id, Kalaha, Gh_Vahed, Name_Gorooh, Code_Kala)"
                 + " VALUES ("+ Integer.toString(i)+",'"+valueS[i] +"','"+valueS[i+1]+"','"+valueS[i+2]+"','"+valueS[i+3]+ "');");
        }

    }
    catch(IOException e)
    {

    }


    try 
    {

        File sdcard = Environment.getExternalStorageDirectory();
        File file = new File(sdcard,"KalaGorooh.txt");
        StringBuilder text1 = new StringBuilder();
        BufferedReader br1 = new BufferedReader(new FileReader(file));
        String line;
        while ((line = br1.readLine()) != null) {
            text1.append(line);
        }
        String TableName = "Tbl_KalaGorooh";
        String[] valueS = text1.toString().split(";");
        myDB.execSQL("DROP TABLE IF EXISTS Tbl_KalaGorooh");
     // "IF NOT EXIT" ro baraye test bardashtam
        myDB.execSQL("CREATE TABLE Tbl_KalaGorooh (id int, Name_Gorooh VARCHAR);");
        for (int i=0; i<valueS.length; i++)
        {

        myDB.execSQL("INSERT INTO "
                 + TableName
                 + " (id, Name_Gorooh)"
                 + " VALUES ("+ Integer.toString(i)+",'"+valueS[i] + "');");
        }

    }
    catch(IOException e)
    {

    }

    ////////khundane file text baraye Kala va Ejade Table ta inja */





}
 public void onDestroy()
    {
        super.onDestroy();
        ArrayList<Activity> activities=new ArrayList<Activity>();
        activities.remove(this);
    }

}

4

2 回答 2

1

在您的第一个活动中,只需在操作 Intent i = new Intent (this,SecoundActivity.class) 上编写此代码;开始活动(一);

在后按的第二个活动中只是做

结束();

这段代码工作正常,我没有得到任何白屏

于 2013-10-14T06:21:15.647 回答
0

也许延迟是在您的第一次活动中;onResume 中的某些内容需要一段时间才能完成。这看起来像后退按钮需要一段时间才能执行,但实际上是第一个尝试加载的活动导致延迟。

解决方案:在 AsyncTask 中启动长时间运行的进程。您可以在加载过程时放置一个加载栏或某种“请稍候”对话框 - 或者如果您真的不需要它来显示您的 UI,请使用占位符并在加载完成后加载数据。

这样,您的 onResume 将在 AsnycTask 上调用 execute() 后返回,并且您的 UI 将立即显示。要加载的数据可以稍后进来。

于 2013-10-14T09:19:57.893 回答