我正在构建一个显示名片的应用。我有一个滚动视图,显示所有卡片的缩略图。显示这些微缩模型的好方法是什么?我目前正在使用片段,但这些对性能有很大影响!我想我可以使用ImageView和Image。但是我如何从应用程序内部获取此图像?
private void displayAvailableCards() {
int numCards = cm.getSize();
RelativeLayout rootView =
(RelativeLayout)myCardsActivityView.findViewById(R.id.frg_myCards_rv_root);
for (int i=0;i<numCards;i++) {
int id=addFrame(i+1,rootView);
addCardToFrame(i,id);
}
}
private int addFrame(int id,RelativeLayout rootView) {
RelativeLayout.LayoutParams params =
new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.BELOW, id - 1);
FrameLayout fm = new FrameLayout(getActivity().getApplicationContext());
fm.setOnClickListener(this);
fm.setId(id);
fm.setLayoutParams(params);
rootView.addView(fm);
return fm.getId();
}
private void addCardToFrame(int i,int id) {
CardViewFragment cvf = getNewCardViewFragment(i);
FragmentManager fm = getFragmentManager();
FragmentTransaction fs = fm.beginTransaction();
fs.add(id, cvf);
fs.commit();
}