java.lang.NullPointerException: Attempt to invoke virtual method 'int android.text.Layout.getLineForOffset(int)' on a null object reference

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Solutions on the web

via Stack Overflow by Bhushan Babar
, 1 year ago
Attempt to invoke virtual method 'int android.text.Layout.getLineForOffset(int)' on a null object reference
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.text.Layout.getLineForOffset(int)' on a null object reference
at com.example.tabstrial2.TabFragment1.getCurrentCursorLine(TabFragment1.java:451)
at com.example.tabstrial2.TabFragment1$2.onTextChanged(TabFragment1.java:169)
at android.widget.TextView.sendOnTextChanged(TextView.java:7689)
at android.widget.TextView.setText(TextView.java:4070)
at android.widget.TextView.setText(TextView.java:3925)
at android.widget.EditText.setText(EditText.java:85)
at android.widget.TextView.setText(TextView.java:3900)
at android.widget.TextView.onRestoreInstanceState(TextView.java:3800)
at android.view.View.dispatchRestoreInstanceState(View.java:13754)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2894)
at android.support.v4.app.Fragment.restoreViewState(Fragment.java:477)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1135)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1290)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1638)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:679)
at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1240)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:670)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:632)
at com.example.tabstrial2.MainActivity.onNavigationItemSelected(MainActivity.java:569)
at android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:153)
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:328)
at android.view.View.performClick(View.java:4783)
at android.view.View$PerformClick.run(View.java:19887)
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:5290)
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:911)

Users with the same issue

You are the first who have seen this exception. Write a tip to help other users and build your expert profile.

Know the solutions? Share your knowledge to help other developers to debug faster.