您好我的应用程序存在严重问题。
我使用recyclerview显示图片和文字的信息
没关系。 RecyclerView在小米Mi3上工作得很好
但我尝试在小米Mi4上启动app并冻结应用程序。
我尝试练习一些线条,我知道应用程序冻结在这一行
listdata.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
listtada是private RecyclerView listdata;
当我在Mi4中启动应用程序并且主动命令是↑使用CPU增加40%或更多并且应用程序站在线上,而不是下一步。
我不知道Mi4与Mi3有什么区别。 android 6.0.1 ..
你有什么想法吗?或者如果想要更多信息写,我发送..
______________________________更多代码________________________________________
adapter = new MyRecyclerViewAdapter(IndexActivity.this, list_kone);
listdata.setAdapter(adapter);
listdata.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
my mycyccyclerViewAdapter
ublic class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewAdapter.CustomViewHolder> {
private List<Kon> listKone;
private Activity mact;
public MyRecyclerViewAdapter(Activity mact, List<Kon> listKone) {
this.listKone = listKone;
this.mact = mact;
}
@Override
public int getItemCount() {
return (null != listKone ? listKone.size() : 0);
}
@Override
public CustomViewHolder onCreateViewHolder(ViewGroup viewGroup, final int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.dlazdica_item, null);
CustomViewHolder viewHolder = new CustomViewHolder(view);
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
onItemClickListener.onItemClick(listKone.get(i));
}
};
view.setOnClickListener(listener);
return viewHolder;
}
@Override
public void onBindViewHolder(final CustomViewHolder customViewHolder, final int i) {
final Kon feedItem = listKone.get(i);
mact.runOnUiThread (new Thread(new Runnable() {
public void run() {
customViewHolder.viewpager.setAdapter(new SamplePagerAdapter(listKone,i,mact));
customViewHolder.indicator.setViewPager(customViewHolder.viewpager);
}
}));
customViewHolder.txtnadpis.setText(listKone.get(i).getJazyky(0).getNadpis());
// txtvhodnypre.setText(listKone.get(i).getNarodenie());
customViewHolder.txtcena.setText(Integer.toString(listKone.get(i).getCena()));
try {
Calendar cal = Calendar.getInstance();
String[] arrdatum = listKone.get(i).getNarodenie().split("-");
cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(arrdatum[2]));
cal.set(Calendar.MONTH, Integer.parseInt(arrdatum[1]));
cal.set(Calendar.YEAR, Integer.parseInt(arrdatum[0]));
Date narodenie = cal.getTime();
customViewHolder.txtvek.setText(Integer.toString((int) ((Calendar.getInstance().getTime().getTime() - narodenie.getTime()) / 1000 / 60 / 60 / 24 / 365.25)));
} catch (Exception e){
customViewHolder.txtvek.setText("neuvedené");
}
customViewHolder.txtheigh.setText(Integer.toString(listKone.get(i).getVyska())+"cm");
// txtlokalina.setText(Integer.toString(listKone.get(i).getCena()));
customViewHolder.cutpopis.setText(listKone.get(i).getJazyky(0).getPopis());
String[] arrplemena = mact.getResources().getStringArray(R.array.plemena);
customViewHolder.txtplemeno.setText(arrplemena[listKone.get(i).getPlemeno()]);
// Then later, when you want to display image
}
class CustomViewHolder extends RecyclerView.ViewHolder {
TextView txtnadpis,txtvhodnypre,txtcena,txtvek,txtheigh,txtplemeno,txtlokalina,cutpopis;
ViewPager viewpager;
CircleIndicator indicator;
CustomViewHolder(View view) {
super(view);
viewpager = (ViewPager) itemView.findViewById(R.id.viewPager2);
indicator = (CircleIndicator) itemView.findViewById(R.id.indicator);
txtnadpis = (TextView)itemView.findViewById(R.id.nadpis);
txtvhodnypre = (TextView)itemView.findViewById(R.id.vhodnyppre);
txtcena = (TextView)itemView.findViewById(R.id.txt_cena);
txtvek = (TextView)itemView.findViewById(R.id.txt_vek);
txtheigh = (TextView)itemView.findViewById(R.id.txtheigh);
txtplemeno = (TextView)itemView.findViewById(R.id.txt_breed);
txtlokalina = (TextView)itemView.findViewById(R.id.txt_lokalita);
cutpopis = (TextView)itemView.findViewById(R.id.cutpopis);
}
}
public interface OnItemClickListener {
void onItemClick(Kon item);
}
private OnItemClickListener onItemClickListener;
public OnItemClickListener getOnItemClickListener() {
return onItemClickListener;
}
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
this.onItemClickListener = onItemClickListener;
}
}
答案 0 :(得分:0)
我检查了权限并且在小米Mi4上我还没有允许所有人。