-2
最近我想在textview中獲取特定的行文本,並且我想使用webview加載文本,我發現了一些代碼引用,我認爲是有用的,但不適合我。如何在textview中獲得特定的行文本並使用webview加載文本(url)
的TextView:
A
Http://ABC.com.jp
C
我想加載線2網址。
最近我想在textview中獲取特定的行文本,並且我想使用webview加載文本,我發現了一些代碼引用,我認爲是有用的,但不適合我。如何在textview中獲得特定的行文本並使用webview加載文本(url)
的TextView:
A
Http://ABC.com.jp
C
我想加載線2網址。
對不起,我的責任很小,現在我仍在更新和修改我的源代碼,我是java新手,除了我會繼續學習,這不是我的主要利益。
Target =(TextView)findViewbyid(R.id.abc);
myTextView = (TextView)findViewbyid(R.id.id1);
int startL= myTextView.getLayout().getLineStart(2);
//^start line
int endL = myTextView.getLayout().getLineEnd(3);
//^end line
String getResults = myTextView.getText().substring(startL, endL);
Target.setText(getResults);
//benefits of using get line end & start is that it can select multiple line content from a large content,also it can be used in selecting single line or specific line.
我做了一些測試之前,我嘗試在webview.I試圖textView.getLayout()。getLineStart(INT線)和getLineEnd(),然後當我進入app.I不知道我爲什麼墜毀,但代碼沒有顯示錯誤。 –
另外我不知道如何記錄錯誤,所以我不能捕獲錯誤代碼 –
我假設textView的意思是'android.widget.TextView',並且您正在嘗試獲取第二行的內容?這取決於你使用的是什麼開發環境,eclipse在logcat中顯示它的錯誤:http://www.androidcentral.com/sites/androidcentral.com/files/postimages/9274/nyanlogcat.jpg – KompjoeFriek