Java.lang.IllegalStateException: Already attached

前端 未结 4 1527
Happy的楠姐
Happy的楠姐 2021-01-07 19:50

I\'m trying to build an app, that pastes an input from a previous activity(works with no problem) and then shows me some things from a database(when ButtonGet is pressed). T

相关标签:
4条回答
  • 2021-01-07 20:25

    Problem is you first initialize textView1, and perform the button click, at that point you are just resetting any previous settings by calling onCreate() again, and before perfomClick methods hits getData() method, inside here also tries to access the text from textView1 but you called onCreate after that and set the view from scratch. That is why you cannot get it work, delete the duplicate code

    0 讨论(0)
  • 2021-01-07 20:29

    If none of the answers here helped - and the Log message makes no sense - I recommend you to File->Invalidate cahce then run the app again and hopefully this time the log will show the correct stack trace.

    0 讨论(0)
  • 2021-01-07 20:35

    In your onCreate, you're calling super.onCreate() twice, and also setContentView() twice. I'm pretty sure that's not what you want to do.

    0 讨论(0)
  • 2021-01-07 20:46

    Please attach logcat message and if possible DB file. This could be the possible problem, You might be reassign the already assigned db object while inserting in the table.

    0 讨论(0)
提交回复
热议问题