这是我的xml,它位于我活动中出现的片段上.
android:id="@+id/frame1"
android:layout_width="wrap_content"
android:layout_height="115dp"
android:layout_margin="2dp"
android:layout_weight="0.33">
android:id="@+id/whoamiwith"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:src="@drawable/default_image" />
这是我的java代码:
@Override
public void onClick(View click) {
if (click == profileBtn) {
whoamiwith.setBackgroundResource(R.drawable.image_i_wanna_put);
}
}
我正在尝试改变图像视图的图像源,没有语法错误,但是当我执行按钮时,仿真器给我一个关闭力,而在logcat上它表示java.lang.NULLPointerException,它的指向to the whoamiwith.setBackgroundResource(R.drawable.loginbtn);线.