import android.view.View.OnClickListener;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.widget.Button.*;
import android.widget.Button.*;
import android.content.*;
import android.net.*;
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button Button1 = (Button) findViewById(R.id.Button1);
Button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.naver.com"));
startActivity(myIntent);
Button Button2 = (Button) findViewById(R.id.Button2);
Button2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=com.snowbound.pockettool.free&feature=nav_result#?t=W251bGwsMSwyLDNd"));
startActivity(myIntent);
Button Button3 = (Button) findViewById(R.id.Button3);
Button3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=net.zhuoweizhang.pocketinveditor&feature=search_result#?t=W251bGwsMSwxLDEsIm5ldC56aHVvd2VpemhhbmcucG9ja2V0aW52ZWRpdG9yIl0."));
startActivity(myIntent);
}
});}});}});}}
요렇게 햇는데
버튼1을 눌러야지만 버튼2가 작동하네요...
해결법좀요..ㅜ
Button Button1 = (Button) findViewById(R.id.Button1);
Button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.naver.com"));
startActivity(myIntent);
Button Button2 = (Button) findViewById(R.id.Button2);
Button2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=com.snowbound.pockettool.free&feature=nav_result#?t=W251bGwsMSwyLDNd"));
startActivity(myIntent);
Button Button3 = (Button) findViewById(R.id.Button3);
Button3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=net.zhuoweizhang.pocketinveditor&feature=search_result#?t=W251bGwsMSwxLDEsIm5ldC56aHVvd2VpemhhbmcucG9ja2V0aW52ZWRpdG9yIl0."));
startActivity(myIntent);
}
});}});}});}}
아래와 같이 만들면 따로따로 되실껍니다....
Button Button1 = (Button) findViewById(R.id.Button1);
Button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.naver.com"));
startActivity(myIntent);
}
});
Button Button2 = (Button) findViewById(R.id.Button2);
Button2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.snowbound.pockettool.free&feature=nav_result#?t=W251bGwsMSwyLDNd"));
startActivity(myIntent);
}
});
Button Button3 = (Button) findViewById(R.id.Button3);
Button3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=net.zhuoweizhang.pocketinveditor&feature=search_result#?t=W251bGwsMSwxLDEsIm5ldC56aHVvd2VpemhhbmcucG9ja2V0aW52ZWRpdG9yIl0."));
startActivity(myIntent);
}
});
버튼2의 클릭 리스너가 버튼1의 클릭 리스너에 들어가있습니다.
이게 무슨말이냐면, 버튼 1을 눌러서 버튼1의 클릭리스너 메소드가 호출되어 이때 버튼2의 클릭리스너가 등록됩니다.
그래서 버튼1을 클릭한 이후에 버튼2 클릭에 반응하는거구요,..
버튼2의 클릭 리스너를 oncreate메소드로 빼세요.