package ex.button1.button1project;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class Button1Activity extends Activity {
Activity act = this;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViewById(R.id.button1).setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
Toast.makeText(act, "첫번째 버튼을 클릭했습니다.",Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.naver.com"));
act.startActivity(intent);
}
});
}
}
저기 R에 빨간줄이 그였구요 저거 없애려고 컨트롤쉬프트O하면 R.layout.main<< 메인에 빨간줄이 그여요 ㅠㅠ 어케해야되지요;
Resource 클래스를 import 해야 합니다.
project explorer에서 get패키지 아래에 R이라는 클래스가 생성되었는지 확인하시고,
본 소스코드 import에 추가해 주셔야 합니다. (보통은 자동 임포트를 하는데 말이죠)
예시)
import ex.button1.button1project.R;