2017-07-25 58 views
-5

Android工作室沒有錯誤消息。點擊圖片按鈕時不會響應。按鈕沒有任何操作

我已經看過類似的問題,但沒有一個是針對我的問題,並沒有幫助

XML文件:

<de.hdodenhof.circleimageview.CircleImageView 
     android:layout_width="85dp" 
     android:layout_height="85dp" 
     android:src="@drawable/noprofileimg" 
     android:id="@+id/profilepic" 
     android:layout_marginBottom="37dp" 
     android:layout_alignBottom="@+id/imageView" 
     android:layout_centerHorizontal="true" /> 
<Button 
    android:id="@+id/pick_image_button" 
    android:layout_width="80dp" 
    android:layout_height="23dp" 
    android:text="Pick Image" 
    android:textSize="12dp" 
    android:padding="0dp" 
    android:background="@color/Gray" 
    android:layout_marginBottom="13dp" 
    android:layout_above="@+id/linearLayout" 
    android:layout_centerHorizontal="true" 
    android:onClick="onClick" 
    /> 

活動文件,

public class uploadprofileimg extends ActionBarActivity{ 


private static final int PICK_IMAGE = 100; 
private ImageView imageView; 

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

    imageView = (ImageView) findViewById(R.id.profilepic); 

    Button pickImageButton = (Button) findViewById(R.id.pick_image_button); 
    pickImageButton.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      openGallery(); 
     } 
    }); 
} 

private void openGallery() { 
    Intent gallery = 
      new Intent(Intent.ACTION_PICK, 
        android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI); 
    startActivityForResult(gallery, PICK_IMAGE); 
} 

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 
    if (resultCode == RESULT_OK && requestCode == PICK_IMAGE) { 
     Uri imageUri = data.getData(); 
     imageView.setImageURI(imageUri); 
    } 
} 

}

這是我的logcat:

07-25 11:51:36.776 28107-28107/com.liamthedeveloper.foodiez E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]] 07-25 11:51:36.776 28107-28107/com.liamthedeveloper.foodiez V/BoostFramework: BoostFramework() : mPerf = null 07-25 11:51:37.080 28107-28107/com.liamthedeveloper.foodiez D/[email protected][ProfileActivity]: ViewPostImeInputStage processPointer 
+0

請添加您的logcat。 – Akriti

+0

@Akriti 07-25 11:51:36.776 28107-28107/com.liamthedeveloper.foodiez E/BoostFramework:BoostFramework():Exception_1 = java.lang.ClassNotFoundException:未找到類「com.qualcomm.qti.Performance」在路徑上:DexPathList [[],nativeLibraryDirectories = [/ system/lib64,/ vendor/lib64]] 07-25 11:51:36.776 28107-28107/com.liamthedeveloper.foodiez V/BoostFramework:BoostFramework():mPerf = null 07-25 11:51:37.080 28107-28107/com.liamthedeveloper.foodiez D/ViewRootImpl @ 435aa35 [ProfileActivity]:ViewPostImeInputStage processPointer 1 – liam

+5

將其添加到問題中。還有一句**警告**:永遠不會像你剛剛那樣做了那些「垃圾」內容「豎起來......」我猜你知道我在說什麼。 – GhostCat

回答

5

從xml中的Button標記中刪除android:onClick="onClick"

+1

是的,刪除它... onClickListener已經由(java)代碼完成! – deHaar

1

您對onclicklistener和onclick屬性都具有相同的活動。您可以簡單地刪除onclick或只是將「onclick」更改爲您已經命名方法的opengallery