第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Java Android 從回調(diào)線程修改成員變量

Java Android 從回調(diào)線程修改成員變量

慕慕森 2021-09-29 17:19:06
基本上,我試圖從 Api 回調(diào)響應中獲取一些值,然后將這些值分配給我的一些成員變量,但似乎程序每次都必須運行我的 getPatientRecord() 方法才能進入我的調(diào)用,這是我以前從未遇到過的。日志輸出結(jié)果是: viewPatient: paitient method viewPatient: secondHello worldnullnull 100SN9 - David Hello HMH 1971-08-09這是我的代碼:public class ViewPatientRecord extends AppCompatActivity{TextView tvName, tvGender, tvBirthDate, tvAddress;String pGender, pAddress, pBirthdate;String pName = "Hello world";Patient myPatient;@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.view_patient_record);    tvName = findViewById(R.id.tvFullName);    tvGender = findViewById(R.id.tvGender);    tvBirthDate = findViewById(R.id.tvDb);    tvAddress = findViewById(R.id.tvAddress);    myPatient= new Patient();    try {        getPatientRecord();    } catch (InterruptedException e) {        e.printStackTrace();    }}private void getPatientRecord() throws InterruptedException {    SharedPreferences myPre = getSharedPreferences("PatientRecord", MODE_PRIVATE);    if(myPre.getString("uuid",null)!=null){        retrievePatientByUuid(myPre.getString("uuid",null));        Log.d("viewPatient", "second"+pName+pGender+pBirthdate);        tvName.setText(pName);        tvGender.setText(pGender);        tvBirthDate.setText(pBirthdate);        tvAddress.setText(pAddress);    }else{        Toast.makeText(ViewPatientRecord.this, "Something went wrong, please contact the administrator for help!", Toast.LENGTH_SHORT).show();    }}
查看完整描述

1 回答

?
慕萊塢森

TA貢獻1810條經(jīng)驗 獲得超4個贊

我看不出問題。調(diào)用在retrievePatientByUuid其中由調(diào)用完成getPatientRecord。所以是的,你必須通過getPatientRecord。調(diào)用是異步的。您應該在回調(diào)中設置 TextViews :


    tvName.setText(pName);

    tvGender.setText(pGender);

    tvBirthDate.setText(pBirthdate);

    tvAddress.setText(pAddress);


查看完整回答
反對 回復 2021-09-29
  • 1 回答
  • 0 關(guān)注
  • 228 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號