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

주소록 관련소스인데 안되는 이유좀알려주세요 ㅜㅜ

0 추천

public class MainActivity2 extends Activity {
    String tag = "cap";
    String [] name, new_name;
    int count = 0;
    ListView listView;
 

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list);
        Cursor cursor = getURI();  // 전화번호부 가져오기
        int end = cursor.getCount(); // 전화번호부의 갯수 세기
        name = new String[end];   // 전화번호부의 이름을 저장할 배열 선언

        String[] bbStr = cursor.getColumnNames();
        for(int i=0; i<bbStr.length;i++)
            // 각각의 컬럼 이름 확인
            Log.e(tag, "ColumnName " + i + " : " + cursor.getColumnName(i));

        if(cursor.moveToFirst()) {    //항상 처음에서 시작
            do {
                if(!cursor.getString(2).startsWith("01")) // 01로 시작하는 핸펀만
                    continue;         // 이멜주소만 있는것은 제외
                // 요소값 얻기
                name[count] = cursor.getString(1);  //이름
                name[count] += "\n";
                name[count] += cursor.getString(2);  //전번
                count++;
            } while(cursor.moveToNext());

            new_name = new String[count];    //이멜주소 제외한 01번호 가져오기
            for(int i=0; i<count; i++) new_name[i] = name[i];  //복사
        }
        cursor.close(); // 반드시 커서 닫고

        listView = (ListView) findViewById(R.id.list);
       

      ArrayAdapter<String> adapter =
                new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new_name);

        listView.setAdapter(adapter);

        listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);  // 반드시 설정해줘야 멀티초이스

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String mes="";
                long num[] = listView.getCheckItemIds();  // 현재 체크된 id들의 배열 리턴
                if(num.length>5) {        // 최대 선택가능 갯수 제한
                    listView.setItemChecked(position, false); // 강제로 언첵
                    Toast.makeText(MainActivity2.this,
                            "5개까지만 선택이 가능합니다.",
                            Toast.LENGTH_SHORT).show();
                    return;
                }

}

chobojin (200 포인트) 님이 2015년 11월 30일 질문
11-30 23:18:16.152 22155-22155/? I/SELinux: Function: selinux_android_load_priority [0], There is no sepolicy file.
11-30 23:18:16.152 22155-22155/? I/SELinux:  
11-30 23:18:16.172 22155-22155/? I/SELinux: Function: selinux_android_load_priority , spota verifySig and checkHash pass. priority version is VE=SEPF_SHV-E330S_4.4.2_0032
11-30 23:18:16.172 22155-22155/? I/SELinux:  
11-30 23:18:16.172 22155-22155/? I/SELinux:  
11-30 23:18:16.172 22155-22155/? I/SELinux: selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
11-30 23:18:16.172 22155-22155/? E/dalvikvm: >>>>> Normal User
11-30 23:18:16.172 22155-22155/? E/dalvikvm: >>>>> com.example.jh.test3 [ userId:0 | appId:10373 ]
11-30 23:18:16.182 22155-22155/? D/dalvikvm: Late-enabling CheckJNI
11-30 23:18:16.332 22155-22155/com.example.jh.test3 W/ApplicationPackageManager: getCSCPackageItemText()
11-30 23:18:16.332 22155-22155/com.example.jh.test3 I/PersonaManager: getPersonaService() name persona_policy
11-30 23:18:16.502 22155-22155/com.example.jh.test3 I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
11-30 23:18:16.502 22155-22155/com.example.jh.test3 I/Adreno-EGL: OpenGL ES Shader Compiler Version: E031.24.00.08+13
11-30 23:18:16.502 22155-22155/com.example.jh.test3 I/Adreno-EGL: Build Date: 03/20/14 Thu
11-30 23:18:16.502 22155-22155/com.example.jh.test3 I/Adreno-EGL: Local Branch: 0320_AU200_patches
11-30 23:18:16.502 22155-22155/com.example.jh.test3 I/Adreno-EGL: Remote Branch:
11-30 23:18:16.502 22155-22155/com.example.jh.test3 I/Adreno-EGL: Local Patches:
11-30 23:18:16.502 22155-22155/com.example.jh.test3 I/Adreno-EGL: Reconstruct Branch:
11-30 23:18:16.552 22155-22155/com.example.jh.test3 D/OpenGLRenderer: Enabling debug mode 0
11-30 23:18:17.022 22155-22155/com.example.jh.test3 D/AndroidRuntime: Shutting down VM
11-30 23:18:17.022 22155-22155/com.example.jh.test3 W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x4173ada0)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime: FATAL EXCEPTION: main
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime: Process: com.example.jh.test3, PID: 22155
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime: java.lang.IllegalStateException: Could not find a method onClick(View) in the activity class com.example.jh.test3.MainActivity for onClick handler on view class android.widget.Button with id 'menu1_button'
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.view.View$1.onClick(View.java:3956)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.view.View.performClick(View.java:4630)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.view.View$PerformClick.run(View.java:19331)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:733)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:157)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5356)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:515)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:  Caused by: java.lang.NoSuchMethodException: onClick [class android.view.View]
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at java.lang.Class.getConstructorOrMethod(Class.java:472)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at java.lang.Class.getMethod(Class.java:857)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.view.View$1.onClick(View.java:3949)
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.view.View.performClick(View.java:4630) 
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.view.View$PerformClick.run(View.java:19331) 
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:733) 
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95) 
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:157) 
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5356) 
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method) 
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:515) 
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265) 
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 
11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method) 
11-30 23:18:36.732 22155-22155/com.example.jh.test3 I/Process: Sending signal. PID: 22155 SIG: 9

1개의 답변

0 추천

11-30 23:18:17.022 22155-22155/com.example.jh.test3 E/AndroidRuntime: java.lang.IllegalStateException: Could not find a method onClick(View) in the activity class com.example.jh.test3.MainActivity for onClick handler on view class android.widget.Button with id 'menu1_button'

메뉴1버튼에 지정된 메소드 온클릭을 못 찾는답니다. xml상에서 메소를 지우시던가

메인액티비티에 온클릭을 구현하세요

익명사용자 님이 2015년 12월 1일 답변
...