public class WypadekInformacjeActivity extends Activity {
TextView tv1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wypadek);
WebView webView = (WebView) findViewById(R.id.webView);
// webView.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);
webView.setBackgroundColor(0);
LoadText lt = new LoadText();
String html = lt.load(R.raw.wypadek, this);
webView.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);
Pattern pattern = Pattern.compile("\\d{3}?");
tv1 = (TextView) findViewById(R.id.textView1);
tv1.setAutoLinkMask(0);
// Linkify.addLinks(tv1, pattern, "tel: ");
// tv1.setAutoLinkMask(Linkify.PHONE_NUMBERS);
}
}
错误/AndroidRuntime(28184):致命异常:主要
...
引起:com.example.swubezpieczenia.WypadekInformacjeActivity.onCreate(WypadekInformacjeActivity.java:29) 处的 java.lang.NullPointerException
当我尝试 setAutoLinkMask(0) 时会发生这种情况。这是第 29 行:“tv1.setAutoLinkMask(0);”。当我评论这一行时,也不例外。