0

i have i button and one flipperview in my layout. When start the activity, activity is parsing a xml. But sometimes this process is take so long time. And i cant click the button while parsing continue.

new Thread() {
        @Override
        public void run() {

            getJSONFromUrl("getVitrinSliderJSON.php?");

            mHandler.sendEmptyMessage(0);
        }
    }.start();


    /*****
     * Start Set Main Page Buttons
     */
    Button btnkesfet = (Button) findViewById(R.id.ana_btn_kesfet);
    btnkesfet.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            Intent i = new Intent(MyAntalyaActivity.this,
                    KesfetAnasayfa.class);
            startActivity(i);
        }
    });


Handler mHandler = new Handler() {
    public void handleMessage(android.os.Message msg) {
        jParse(jObj);

        SetFlipper();

    };
};
4

2 回答 2

0

您将需要一个布尔变量以防止用户在 xml 解析期间单击按钮,并在解析后使用 button.setEnabled禁用或启用按钮

于 2012-07-02T12:33:59.890 回答
0

我假设你想把jParse(jObj);你必须避免锁定 UI 线程的线程放在里面。

于 2012-07-02T13:12:44.537 回答