안녕하세요? ㅎㅎ 토스트로 아래처럼 소스를 짰더니, 토스트가 안멈추네요 ㅎㅎ
가령 토스트메세지가 1부터 6까지 나오는데, 중간에 스톱버튼 누르면 멈춰야하는데 안멈추고 계~속 나와요 ㅠㅠ
왜그런거죠? 토스트를 멈출길은 정녕 없나요 ^^
----------------------------
package com.commonsware.android.messages;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MessageDemo extends Activity implements View.OnClickListener {
Button toast;
Button toaststop;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
toaststop=(Button)findViewById(R.id.toaststop);
toaststop.setOnClickListener(this);
toast=(Button)findViewById(R.id.toast);
toast.setOnClickListener(this);
}
public void onClick(View view) {
if (view==toast) {
Toast.makeText(this, "토스트 메시지1", Toast.LENGTH_SHORT).show();
if (view==toaststop){
Toast.makeText(this, "stopped", Toast.LENGTH_SHORT).cancel();
}
Toast.makeText(this, "토스트 메시지2", Toast.LENGTH_SHORT).show();
if (view==toaststop){
Toast.makeText(this, "stopped", Toast.LENGTH_SHORT).cancel();
}
Toast.makeText(this, "토스트 메시지3", Toast.LENGTH_SHORT).show();
if (view==toaststop){
Toast.makeText(this, "stopped", Toast.LENGTH_SHORT).cancel();
}
Toast.makeText(this, "토스트 메시지4", Toast.LENGTH_SHORT).show();
if (view==toaststop){
Toast.makeText(this, "stopped", Toast.LENGTH_SHORT).cancel();
}
Toast.makeText(this, "토스트 메시지5", Toast.LENGTH_SHORT).show();
if (view==toaststop){
Toast.makeText(this, "stopped", Toast.LENGTH_SHORT).cancel();
}
Toast.makeText(this, "토스트 메시지6", Toast.LENGTH_SHORT).show();
if (view==toaststop){
Toast.makeText(this, "stopped", Toast.LENGTH_SHORT).cancel();
}
}
}
}
비교가 잘못됐네요..
if("toast".equals(view.getId())) {
}
요런식으로..