我有一个botton导航活动,我想使用ontouchlistener,如:
@SuppressLint("ClickableViewAccessibility")
@Override
public void onResume() {
super.onResume();
CancelType = (TextView) findViewById(R.id.UCancel);
CancelType.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
android.support.v4.app.Fragment fragment = null;
fragment = new ProvinceFragment();
if(fragment != null ){
android.support.v4.app.FragmentTransaction ft =
getSupportFragmentManager().beginTransaction();
ft.replace(R.id.content , fragment );
ft.commit();
}
return false;
}
});
}
当我使用此代码时,我的应用程序崩溃了? 有了这个:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to resume activity
{com.example.mostafa.passenger/com.example.mostafa.passenger.MotelsActivity}:
java.lang.NullPointerException
请帮助。