2017-06-22 107 views
-1

你好,我的應用程序有一個大問題。LinearLayoutManager在某些設備上被凍結的應用程序

我使用recyclerview顯示圖片和文字的信息

沒關係。 RecyclerView工作好...關於小米Mi3

但我被tryed在小米Mi4上啓動應用程序並凍結了應用程序。

我嘗試COMENT一些線和我知道,這樣的應用程序凍結在這一行

listdata.setLayoutManager(new LinearLayoutManager(getApplicationContext())); 

listtada是private RecyclerView listdata;

,當我在MI4和積極的命令來啓動應用程序中使用40%的CPU增加或↑更多和應用程序站在線上,而不是下一步。

我不知道它是如何與Mi3的Mi4差異。 android 6.0.1 ..

你有一些想法嗎?或者,如果想了解更多的信息寫,我送..

______________________________more code________________________________________

adapter = new MyRecyclerViewAdapter(IndexActivity.this, list_kone); 
         listdata.setAdapter(adapter); 
         listdata.setLayoutManager(new LinearLayoutManager(getApplicationContext())); 

我myRecyclerViewAdapter

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

你試過給linearlayoutmanager方向嗎? –

回答

0

我檢查permissionsand對小米手機4我沒有讓所有。

相關問題