【发布时间】:2017-04-16 12:35:31
【问题描述】:
我有一个活动,我想显示我从数据库中收到的日期。 在 TextView 中显示我的结果,这没问题。但我也想将收到的数据保存在字符串值中。 我的代码: 主要活动:
db3 = new DatabaseC529(C529chooseActivity.this,tvC529Cthirdoccupied,tInt3);
db3.execute(methode, date, timeId3);
数据库C529: 构造函数:
public DatabaseC529(Activity activity, TextView textView, String myValue){
this.activity = activity;
this.ctx = activity;
this.textView = textView;
this.myValue = myValue;}
...
protected void onPostExecute(String result) {super.onPostExecute(result);
this.textView.setText(result);
this.myValue = result;
}
AsyncTask 完成后,Result 显示在 TextView 中。 但我也希望将值存储在我的字符串“tInt3”中。 我创建了一个按钮(只是为了检查是否存储了值)来在 AsyncTask 完成后获取 tInt3 的内容,但它总是显示“null”。 代码按钮:
public void button1 (View view){if(view.getId() == R.id.button1){
Toast.makeText(this, " " +tInt3, Toast.LENGTH_SHORT).show();
}
谁能帮帮我???
【问题讨论】:
-
你在哪里将值存储到 tInt3?
-
谢谢大家,创建界面解决了我的问题