Java Android AsyncTask + mysql connection

前端 未结 1 1817
醉话见心
醉话见心 2020-12-22 01:39

I have a problem, I am trying to connect to a MySQL database using AsyncTask. I put the connection code in the button event but it gives me error,

Here

相关标签:
1条回答
  • 2020-12-22 02:06

    Your error is: TextView tv = (TextView)this.findViewById(R.id.textView1); because it is declared outside of onCreate.

    So this is what you have to do, declare TextView tv; above onCreate. Then inside onCreate you add tv = (TextView) findViewById(R.id.textView1);

    And remove the duplicate of:

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    0 讨论(0)
提交回复
热议问题