[英]In Android Studio, how do you switch a fragment to another fragment using java code
[英]How do you code on a Fragment in android studio
我一直試圖使ListView出現在一個片段上,但是一行阻礙了我這樣做。
ArrayAdapter<String> myAdapter=new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, items);
誰能告訴我該如何糾正此行中的錯誤?
引起我注意的一件事是將“ this”替換為“ getContext()”。
片段本身(這)不是UI操作的有效上下文,而是依賴於基礎Activity的上下文。
所以我的猜測是,您找到的示例旨在在活動中顯示列表,而不是片段。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.