2

質問があります。HttpDownload クラスから AnimalBadger クラスにトーストメッセージを (if 条件で) 表示することはできますか? (どちらのクラスも Activity を拡張します)

if (((Node) textNodes.item(i)).getNodeValue().equals("a waning quarter moon")) 
{
    Toast.makeText(HttpDownload.this, "Some text...", Toast.LENGTH_LONG).show();
} 

答えてくれてありがとう...

4

2 に答える 2

2

The first argument is just to get the Context to create the Toast with. You can use either activity or even getApplicationContext(). For simplicity, you usually use the closest available Context, which in this case would be your containing activity.

Toasts are not sent between application components, they take the form of small notifications usually at the bottom of the screen, and are a way to communicate low-priority messages to the user.

You may want to read the Creating Toast Notifications article in the documentation.

于 2011-03-02T17:01:14.417 に答える
0

コールバック関数を使用して、HttpDownload クラスに登録できます。そのようにして、トーストをスローするコールバックが呼び出されます(しゃれが意図されています)。

于 2011-03-02T17:01:50.947 に答える