我收到这样的错误:
java.lang.RuntimeException:无法启动活动ComponentInfo {com.splash.indivillage.indishare / com.splash.indivillage.indishare.Home.HomeActivity}:java.lang.NullPointerException:尝试调用虚拟方法&#39 ; void android.widget.ImageButton.setOnClickListener(android.view.View $ OnClickListener)'在null对象referenceOnClickListener
上
listener = new OnClickListener() {
@Override
public void onClick(View v) {
/** Getting the fragment manager */
FragmentManager manager = getFragmentManager();
/** Instantiating the DialogFragment class */
AlertDialogRadio alert = new AlertDialogRadio();
/** Creating a bundle object to store the selected item's index */
Bundle b = new Bundle();
/** Storing the selected item's index in the bundle object */
b.putInt("position", position);
/** Setting the bundle object to the dialog fragment object */
alert.setArguments(b);
/** Creating the dialog fragment object, which will in turn open the alert dialog window */
alert.show(manager, "alert_dialog_radio");
}
};
/** Getting the reference of the button from the main layout */
ImageButton abuseBtn = (ImageButton) findViewById(R.id.abuseImageView);
/** Setting a button click listener for the choose button */
abuseBtn.setOnClickListener(listener);
Log.d(TAG, "onCreate: starting.");