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

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

按字母順序排序更改 ArrayList 中項目的位置,因此單擊偵聽器不匹配

按字母順序排序更改 ArrayList 中項目的位置,因此單擊偵聽器不匹配

手掌心 2021-06-25 10:09:33
我制作了一個自定義比較器來按字母順序?qū)ψ远x ArrayList 中的對象進行排序。列表中的項目有一個 OnItemClickListener。我的應用程序是多語言的。當我在設(shè)置中切換語言時,項目會改變它們的位置。因此, OnItemClickListener 失去了與索引中項目位置的匹配。如何鏈接項目的位置以在正確的位置維護點擊偵聽器?這是活動:public class ColorsCatalogue extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_colors_catalogue);        final ArrayList<setTextViewCatalogue> arrayListCatalogo = new ArrayList<>();        arrayListCatalogo.add(new setTextViewCatalogue(getResources().getString(R.string.codice_arancione), getResources().getString(R.string.sfumature_di_arancione), getResources().getString(R.string.codice_arancione)));        arrayListCatalogo.add(new setTextViewCatalogue(getResources().getString(R.string.codice_bianco), getResources().getString(R.string.sfumature_di_bianco), getResources().getString(R.string.codice_bianco)));        arrayListCatalogo.add(new setTextViewCatalogue(getResources().getString(R.string.codice_blu), getResources().getString(R.string.sfumature_di_blu), getResources().getString(R.string.codice_blu)));        Collections.sort(arrayListCatalogo, new AlphabeticalComparator());        setTextViewCatalogueAdapter adapter = new setTextViewCatalogueAdapter(this,arrayListCatalogo);        ListView listView = findViewById(R.id.catalogueListView);        listView.setAdapter(adapter);        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {            @Override            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {                if (i == 0) {                    Intent goToShadesOfOrange = new Intent(ColorsCatalogue.this, ShadesOfOrange.class);                    startActivity(goToShadesOfOrange);                }            }        });    }}
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 153 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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