마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 책보고 한지 2일되었는데요

0 추천

do it 책보고 하고있는데

2일째입니다. 

학원 컴퓨터가 안좋아서 가상 머신이 잘안돌아가는데요

그래서 그냥 스마트폰 물려서 할려고하는데 간단한 소스에서도 오류가 나네요 

왜인지는 모르겠씁니다 책에 있는 그대로 했는데

버튼눌러서 웹페이지 띄우는건 되는데

전화기능이랑 새로운 액티비티 여는건 안되네요

구동 프로그램은 안드로이드 스튜디오입니다.

 

package org.androidtown.test1;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;


public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void onButton1Clicked(View v) {
//        Toast.makeText(getApplicationContext(), "버튼이 눌렸어요", Toast.LENGTH_LONG).show();

        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://m.gooogle.com"));
        startActivity(intent);//버튼으로 웹페이지 띄우기
    }

    void onButton2Clicked(View v) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:010-7104-9218"));
        startActivity(intent);//전화걸기 띄우기

    }

    void onButton3Clicked(View v) {
        Intent intent = new Intent(getApplicationContext(), NewActivity.class);
        startActivity(intent);//새로운창 띄우기
}




    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

 

http://www.masterqna.com/android/ask# 님이 2015년 5월 7일 질문

1개의 답변

0 추천
xml 해당 버튼에 onClick 정의가 안되어 있거나.. 안되는 두 버튼 클림 함수의 접근자를 public으로 지정해 줘보세요
익명사용자 님이 2015년 5월 7일 답변
감사합니다 해결되었습니다.
문제가 해결되었으면 댓글만 달지 마시고 답변 채택을 하셔용~
...