이미지버튼 2개생성
첫번째 버튼 눌렀을때 -->다른 액티비티로 가기 까지 되었는데요.
두번째 버튼 이벤트도 추가하려고 하는데요.
빨간색부분처럼 추가 하였습니다.
이런식으로 추가하는거 아닌가요??
소스상에는 에러가 안뜨는데...
run하면, 실행이 안됩니다...
메인 패키지에만 x 로 표시되구요...
package exam.EtriProblemStatement;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class EtriProblemStatement extends Activity implements OnClickListener{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton button = (ImageButton) findViewById(R.id.Car1);
button.setOnClickListener(this);
ImageButton button2 = (ImageButton) findViewById(R.id.Car2); <----------------이부분
button2.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.Car1){
Intent intent = new Intent(this, Lamborghini.class);
startActivity(intent);
}
if (v.getId() == R.id.Car2){ <----------------이부분
Intent intent2 = new Intent(this, Ferrari.class);
startActivity(intent2);
}
}
}