我在線路錯誤顯示片段Onclik
出於傳遞活動FragmentManager FM = getFragmentManager();
。任何解決方案時,我點擊¿所以我need¿。謝謝和對不起I'm小白
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewHolders> {
private List<ItemObject> itemList;
private Context context;
public RecyclerViewAdapter(Context context, List<ItemObject> itemList) {
this.itemList = itemList;
this.context = context;
}
@Override
public RecyclerViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_view_list, null);
RecyclerViewHolders rcv = new RecyclerViewHolders(layoutView);
return rcv;
}
@Override
public void onBindViewHolder(final RecyclerViewHolders holder, final int position) {
holder.cardText.setText(itemList.get(position).getName());
holder.cardPhoto.setImageResource(itemList.get(position).getPhoto());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
switch (position){
case 0:
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.frameLayout, new FragmentNewGame(), "newGame");
ft.addToBackStack(null);
ft.commit();
什麼錯誤? – Rohit5k2