Java 当我在导航栏中按“联系我们”时,我的应用程序停止工作
Java 当我在导航栏中按“联系我们”时,我的应用程序停止工作,java,android,Java,Android,ContactUsFragment.java 我浏览了很多帖子,但找不到任何相关的答案。我试图在一个片段中添加一个位置和一些图像,但应用程序正在崩溃。此文件中存在错误。XML文件很好 public class ContactUsFragment extends FragmentActivity implements OnMapReadyCallback { private GoogleMap mMap; public static ContactUsFragment
ContactUsFragment.java
我浏览了很多帖子,但找不到任何相关的答案。我试图在一个片段中添加一个位置和一些图像,但应用程序正在崩溃。此文件中存在错误。XML文件很好
public class ContactUsFragment extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
public static ContactUsFragment newInstance(){
ContactUsFragment fragment = new ContactUsFragment();
return fragment;
}
public ContactUsFragment() {
}
@BindView(R.id.contact_us_root)
LinearLayout root;
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_contact_us, container, false);
ButterKnife.bind(this, rootView);
TextView textView1 = (TextView)findViewById(R.id.t1);
TextView textView2 = (TextView)findViewById(R.id.t2);
TextView textView3 = (TextView)findViewById(R.id.t3);
TextView textView4 = (TextView)findViewById(R.id.t4);
TextView textView5 = (TextView)findViewById(R.id.t5);
TextView textView6 = (TextView)findViewById(R.id.t6);
ImageView imageView = (ImageView)findViewById(R.id.ib1);
imageView.setImageResource(R.drawable.fb1);
ImageView imageView1 = (ImageView)findViewById(R.id.ib2);
imageView1.setImageResource(R.drawable.gp1);
ImageView imageView2 = (ImageView)findViewById(R.id.ib3);
imageView2.setImageResource(R.drawable.pin1);
ImageView imageView3 = (ImageView)findViewById(R.id.ib4);
imageView3.setImageResource(R.drawable.add);
ImageView imageView4 = (ImageView)findViewById(R.id.ib5);
imageView4.setImageResource(R.drawable.phone);
ImageView imageView5 = (ImageView)findViewById(R.id.ib6);
imageView5.setImageResource(R.drawable.gmail);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
return rootView;
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng loc = new LatLng(12.77, 77.52);
mMap.addMarker(new MarkerOptions().position(loc).title("Student Zone"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(loc));
}}
01-18 14:12:04.827 30314-30314/in.astudentzone.studentzone E/UncaughtException: java.lang.NullPointerException: Attempt to write to field 'android.support.v4.app.FragmentManagerImpl android.support.v4.app.Fragment.mFragmentManager' on a null object reference
at android.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:418)
at android.support.v4.app.BackStackRecord.replace(BackStackRecord.java:457)
at android.support.v4.app.BackStackRecord.replace(BackStackRecord.java:449)
at in.astudentzone.studentzone.activities.Home.selectDrawerItem(Home.java:133)
at in.astudentzone.studentzone.activities.Home$1.onNavigationItemSelected(Home.java:66)
at android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:152)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:810)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:957)
at android.support.design.internal.NavigationMenuPresenter$1.onClick(NavigationMenuPresenter.java:318)
at android.view.View.performClick(View.java:4789)
at android.view.View$PerformClick.run(View.java:19881)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
01-18 14:12:04.831 30314-30380/in.astudentzone.studentzone D/FA: Logging event (FE): _ae, Bundle[{_o=crash, _sc=Home, _si=3096521095531764912, timestamp=1484728924827, fatal=1}]
01-18 14:12:05.090 30314-30314/in.astudentzone.studentzone E/AndroidRuntime: FATAL EXCEPTION: main
Process: in.astudentzone.studentzone, PID: 30314
java.lang.NullPointerException: Attempt to write to field 'android.support.v4.app.FragmentManagerImpl android.support.v4.app.Fragment.mFragmentManager' on a null object reference
at android.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:418)
at android.support.v4.app.BackStackRecord.replace(BackStackRecord.java:457)
at android.support.v4.app.BackStackRecord.replace(BackStackRecord.java:449)
at in.astudentzone.studentzone.activities.Home.selectDrawerItem(Home.java:133)
at in.astudentzone.studentzone.activities.Home$1.onNavigationItemSelected(Home.java:66)
at android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:152)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:810)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:957)
at android.support.design.internal.NavigationMenuPresenter$1.onClick(NavigationMenuPresenter.java:318)
at android.view.View.performClick(View.java:4789)
at android.view.View$PerformClick.run(View.java:19881)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
01-18 14:12:06.574 30314-30314/in.astudentzone.studentzone I/Process: Sending signal. PID: 30314 SIG: 9
把你的日志发出去。我该怎么分享日志呢@ReenaSeems我们的ButterKnife没有响应,而是使用
…..(TextView)rootView.findViewById(R.id.t1)使用rootView
的所有代码>均无效:(@W4R10CKCopy Text from'Android Monitor'