亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

填充微調器 [自定義適配器] 改造

填充微調器 [自定義適配器] 改造

紅顏莎娜 2022-05-25 10:45:22
我有一個自定義適配器,我想用它來填充我的微調器。我正在使用改造,我想從 JSon 文件中獲取響應并將其傳遞給微調器。我試圖將列表項調用到微調器,但我被卡住了。我是 android 和 Java 的新手。提前致謝Call<RegistrationDropdownResponse> call = apiService.dropDownresponse(commonRequest);    call.enqueue(new Callback<RegistrationDropdownResponse>() {        @Override        public void onResponse(Call<RegistrationDropdownResponse> call, Response<RegistrationDropdownResponse> response) {            if (response.isSuccessful()) {                Log.e("RESPONSE", new Gson().toJson(response.body()));                Constants.registrationDropdownResponse = response.body();                CustomAdapter adapter = new CustomAdapter(this,);                spCompany.setAdapter(adapter);            }        }        @Override        public void onFailure(Call<RegistrationDropdownResponse> call, Throwable t) {        }    });    這是我的回復課public class RegistrationDropdownResponse {private List<MaritalStatus> marital;private List<IncomeBand> income;private List<EducationLevel> education;private List<Rental> rental;private List<EmploymentLevel> employment;public List<MaritalStatus> getMarital() {    return marital;}public List<IncomeBand> getIncome() {    return income;}public List<EducationLevel> getEducation() {    return education;}public List<Rental> getRental() {    return rental;}public List<EmploymentLevel> getEmployment() {    return employment;}}
查看完整描述

1 回答

?
湖上湖

TA貢獻2003條經驗 獲得超2個贊

好的,所以要實現這一點,您首先需要創建 xml 視圖,例如:


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical">


    <TextView

        android:id="@+id/name_text_view"

        android:layout_width="match_parent"

        android:layout_height="wrap_content" />

</LinearLayout>

現在在函數中的適配器中,getView()您需要對其進行充氣并綁定TextView:


convertView = LayoutInflater.from(context).

                        inflate(R.layout.layout_list_view_row_items, parent, false);

TextView nameTextView = (TextView) convertView.findViewById(R.id.name_text_view);



//and now get the SpinnerArrayObject by position



 SpinnerArrayObject currentObject = spinnerArrayObjects.get(position);

    nameTextView.setText(currentObject.getName());


    return convertView;


查看完整回答
反對 回復 2022-05-25
  • 1 回答
  • 0 關注
  • 77 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號