我从SQLite数据库中获取一些文本并将其放入一个变量中:
opis = c.getString(11);
光标在我的应用程序的其余部分运行良好。 现在,我使用一个意图调用另一个活动并将字符串发送给它:
Intent opis = new Intent(getApplicationContext(), Popup_opis.class);
opis.putExtra("poslatOpis", opis);
startActivity(opis);
在那个类中,我将那个字符串放在另一个类里,并将该文本设置为TextView。当我在TextView中仅调用单词“text”时,弹出式活动可以正常工作。现在这就是那个活动:
public class Popup_opis extends Activity{
TextView opis;
String poslatOpis, primljenOpis;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.popup_opis);
Bundle extras = getIntent().getExtras();
if(extras !=null) {
primljenOpis = extras.getString("poslatOpis");
}
initVariables();
}
private void initVariables() {
Typeface tv = Typeface.createFromAsset(getAssets(), "ARIALN.TTF");
opis = (TextView) findViewById(R.id.tvOpis);
opis.setTypeface(tv);
opis.setText(primljenOpis);
}
}
以下是LogCat:
04-03 13:59:54.424: E/AndroidRuntime(28413): FATAL EXCEPTION: main
04-03 13:59:54.424: E/AndroidRuntime(28413): java.lang.StackOverflowError
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:484)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413): at android.os.Bundle.writeT
我做错了什么?
opis
(TextView
,Intent
,String
...)...通过这行代码opis.putExtra("poslatOpis", opis);
,你将Intent
(而不是String
)作为Extra放入了Intent
中...这就是你最终遇到StackOverflow的原因... - SelvinwriteMapInternal,writeToParcel,writeBundle
正在递归执行,导致Stackoverflow异常,请发布您的先前活动代码。 - Pragnani