Android-Button-Onclick-listener nicht funktioniert

Habe ich zwei Schaltflächen auf meine Aktivität. Man arbeitet perfekt und man ist nicht. Ich kann nicht scheinen, um das problem zu finden. Hier ist der code. Die create_profile - Taste nicht funktioniert. Kann mir bitte jemand sagen, warum?

    private Button create_profile,select_contact;

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.create_main);

    select_contact = (Button)findViewById(R.id.add_contact);
    create_profile = (Button)findViewById(R.id.create_button);

    select_contact.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            final Uri uriContact = ContactsContract.Contacts.CONTENT_URI;
            Intent intentPickContact = new Intent(Intent.ACTION_PICK, uriContact);
            startActivityForResult(intentPickContact, PICK_CONTACT);    
        }
    });

    create_profile.setOnClickListener(new OnClickListener() {

        @SuppressLint("ShowToast")
        @Override
        public void onClick(View arg0) {
            Toast.makeText(getApplicationContext(), "Pressed", Toast.LENGTH_LONG);
            System.out.println("PRessed");

        }
    });
    }

Hier ist der xml-code

          <Button 
                    android:id="@+id/add_contact"
                    android:layout_width="85dp"
                    android:layout_height="wrap_content"
                    android:text="Add"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="2dp"
                    android:textSize="19dp"/>
        <Button 
            android:id="@+id/create_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:text="Create Profile"
            android:textSize="18sp"
            android:layout_marginTop="8dp"/>

Ich habe alles überprüft, kann aber nicht scheinen, um das problem zu finden.

  • entfernen Sie private Modifikatoren aus-Taste
  • Es hat nicht funktioniert.
  • der häufigste Fehler, zu vergessen, um zu zeigen, toast.
InformationsquelleAutor airbourne | 2014-11-09
Schreibe einen Kommentar