0

Android アプリにアクティビティ クラスがあり、データが処理された後、そのデータは別のクラスの別のメソッドに送信され、ArrayList が返されます。私がやりたいことは、その ArrayList を反復処理し、その中のすべてのテキストに対して、インターフェイスの TextView ラベルを更新したいと考えています。ただし、ユーザーが画面上の「はい」ボタンを押すたびに、これを行う必要があります。(つまり、ユーザーが「はい」ボタンを押すたびに、ループは ArrayList の次の要素に進み、その値が TextView ラベルで更新されます)。これが私がこれまでに持っているものです:

try {
        sentenceGenerator = new SentenceGenerator();
        ArrayList<ArrayList<String>> states = stateGenerator
                .getPossibleStates(resultOutput, result, result);
        for (ArrayList<String> state : states) {
            viewPoint = state.get(0);
            subject = state.get(1);
            object = state.get(2);
            subjectInfo = new ObjectReference();
            if (resultOutput.equals("Sliema")) {
                Sliema sliema = new Sliema();
                subjectInfo = sliema.getInfo(viewPoint, object, subject);
            }
            try {
                s = sentenceGenerator.generateSentence("start", "middle",
                        "end", resultOutput, viewPoint, object, subject,
                        subjectInfo.type, subjectInfo.name,
                        subjectInfo.properties, false);
                instructionTextView = (TextView) findViewById(R.id.instructionTextView);
                mHandler = new Handler();
                instructionTextView
                        .setText("Press 'Yes' to start Orientation procedure");
                Button confirmButton = (Button) findViewById(R.id.confirmButton);
                Button declineButton = (Button) findViewById(R.id.declineButton);

                confirmButton
                        .setOnClickListener(new View.OnClickListener() {
                            public void onClick(View v) {
                                mHandler.post(mUpdate);
                            }
                        });
                declineButton
                        .setOnClickListener(new View.OnClickListener() {
                            public void onClick(View v) {
                                //
                            }
                        });
                Log.d("INSTRUCTIONS", s);
            } catch (Exception e) {
            }
        }
    } catch (ClassNotFoundException e) {
    }

これは更新ハンドラです:

private Runnable mUpdate = new Runnable() {
    public void run() {

        instructionTextView.setText(s);
        // mHandler.postDelayed(this, 1000);
        confirmPressed = true;
        // i++;
    }
};

助言がありますか?前もって感謝します!

4

1 に答える 1

0

ループを終了したい場所にabreak;を追加してみてください。buttonclickListener

于 2013-05-10T08:51:58.340 に答える