簡體   English   中英

將textview與arraylist鏈接,並在事件發生時更改文本

[英]Linking a textview with an arraylist and change text when event occurs

因此,基本上我有了textview,我希望將textview附加到字符串的ArrayList,然后根據滑動事件來更改文本。

當我向左或向右滑動時,如何使textview顯示下一個元素文本,當再次滑動時,它將顯示下一個元素文本,依此類推。 當到達最后一個元素時,它將再次循環回到第一個元素。

我已經在此答案中嘗試過刷卡代碼,但是我不知道如何顯示ArrayList中的文本。

能做到嗎..!?

int counter = 0;
@Override
public void onSwipeRight() {
super.onSwipeRight();
if(counter == arraylist.size()}{
      counter =0;
}
 textview.setText(arraylist.get(counter));
 counter++;
});

嘗試這個。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM