我有RecyclerView和适配器:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="wrapper">
<div class="element_wrapper" data-id="20" data-parent="" style="display:none">
<button class="toggler_btn" type="button" data-id="20" data-parent="">+</button> Building 1
<button class="add_btn" type="button">Add</button>
<button class="edit_btn" type="button" data-id="20" data-parent="">Edit</button>
<button class="delete_btn" type="button" data-id="20">Delete</button>
<div class="element_wrapper" data-id="25" data-parent="20" style="display:none">
<button class="toggler_btn" type="button" data-id="25" data-parent="20">+</button> Something Else
<button class="add_btn" type="button">Add</button>
<button class="edit_btn" type="button" data-id="25" data-parent="20">Edit</button>
<button class="delete_btn" type="button" data-id="25">Delete</button>
<div class="element_wrapper" data-id="30" data-parent="25" style="display:none">
<button class="toggler_btn" type="button" data-id="30" data-parent="25">+</button> Something Else
<button class="add_btn" type="button">Add</button>
<button class="edit_btn" type="button" data-id="30" data-parent="25">Edit</button>
<button class="delete_btn" type="button" data-id="30">Delete</button>
</div>
</div>
</div>
我拍摄了两个截屏视频,在此视频中tap gpu的时间轴,在第二个tap时,屏幕会在项目更新时闪烁。在两件奇怪的事情发生。有什么问题?
答案 0 :(得分:0)
我强烈建议您在在RecyclerView中实例化适配器之前将JSONObject解析为ArrayList,并从ArrayList访问每个项目,这可能会导致性能问题。 你可以用Gson做到这一点:
Gson gson = new Gson();
TypeToken<ArrayList<YourValue>> token = new TypeToken<ArrayList<YourValue>>() {};
ArrayList<YourValue> listValues = gson.fromJson(values.toString(), token.getType());