グリッドをrecyclerviewグリッドに変更したので、すべてが問題ないと思いますが、もう少し問題がありました。私は同じ質問を探していましたが、自分の問題を解決しようとしましたが、それ以外はすべて私を助けません。Android RecyclerView:アダプターは接続されていません。レイアウトをスキップする
Log:{
RecyclerView: No adapter attached; skipping layout
}
だから、これは私のコードです:
Database database;
int mId;
boolean isFabOpen;
RecyclerViewGridODAdapter recyclerViewGridODAdapter;
AlertDialog.Builder myDialog;
int[]Ids;
GridAutofitLayoutManager layoutManager;
private Animation fab_open,fab_close,rotate_forward,rotate_backward;
List<OneDayTD> oneDayList;
private static final String TAG = "MyLog";
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container3,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v =inflater.inflate(R.layout.fragment_one_day_tasks,container3,false);
View vds =inflater.inflate(R.layout.content_fragment_one_day_tasks,null);
final View vd =inflater.inflate(R.layout.dialogod,null);
TextView textView= (TextView) v.findViewById(R.id.ActiveMenu);
TextView textView1= (TextView) v.findViewById(R.id.Alert);
database = new Database(v.getContext());
mId = database.getLastIdOD();
if(mId>=1) {
oneDayList = database.getOneDayList(1);
}
database.close();
//dlg1 = new DialogFragment();
final RecyclerView gridView = (RecyclerView) vds.findViewById(R.id.gridViewActiveOd);
layoutManager = new GridAutofitLayoutManager(getActivity().getApplicationContext(), 160);
if(0<mId){
Log.d("myLog","StartAdapter");
Log.d("myLog","oki "+oneDayList.get(0).getTitle());
recyclerViewGridODAdapter =new RecyclerViewGridODAdapter(oneDayList);
gridView.setAdapter(recyclerViewGridODAdapter);//RecyclerView: No adapter attached; skipping layout
gridView.setLayoutManager(layoutManager);//RecyclerView: No adapter attached; skipping layout
gridView.setHasFixedSize(true);
gridView.addOnItemTouchListener(new RecyclerTouchListener(getActivity().getApplicationContext(), gridView, new ClickListener() {
@Override
public void onClick(View view, final int position) {
myDialog = new AlertDialog.Builder(getActivity());
FrameLayout layout = (FrameLayout) vd.findViewById(R.id.dialogod);
final FloatingActionButton tap = (FloatingActionButton) vd.findViewById(R.id.fabTap);
fab_open = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), R.anim.fab_open);
fab_close = AnimationUtils.loadAnimation(getActivity().getApplicationContext(),R.anim.fab_close);
rotate_forward = AnimationUtils.loadAnimation(getActivity().getApplicationContext(),R.anim.rotate_forward);
rotate_backward = AnimationUtils.loadAnimation(getActivity().getApplicationContext(),R.anim.rotate_backward);
final FloatingActionButton remake = (FloatingActionButton) layout.findViewById(R.id.fabRemake);
remake.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().finish();
Intent intent = new Intent(getActivity().getApplicationContext(),CreateOneDayActivity.class);
intent.putExtra("mId", oneDayList.get(position).getId());
startActivity(intent);
Snackbar.make(v, "Task Remake", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
gridView.refreshDrawableState();
}
});
final FloatingActionButton back = (FloatingActionButton) layout.findViewById(R.id.fabBack);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Snackbar.make(v, "Ok back", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
final FloatingActionButton del = (FloatingActionButton) layout.findViewById(R.id.fabDel);
del.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
database = new Database(getActivity());
OneDayTD oneDayTD = database.getOneDay(oneDayList.get(position).getId());
database.deleteOD(oneDayTD);
Intent alarmIntent = new Intent(getActivity(), AlarmReceiver.class);
AlarmUtil.cancelAlarm(getActivity(), alarmIntent, oneDayTD.getId());
database.close();
Snackbar.make(v, "Ok you had put it int the del folder? bit rot some little time", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
final FloatingActionButton copy = (FloatingActionButton) layout.findViewById(R.id.fabClone);
copy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
database = new Database(getActivity());
OneDayTD oneDayTD = database.getOneDay(oneDayList.get(position).getId());
oneDayTD.setId(oneDayList.get(position).getId() + 1);
database.addOT(oneDayTD);
database.close();
Snackbar.make(v, "Ok you had copy that task", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
tap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(isFabOpen){
tap.startAnimation(rotate_backward);
copy.startAnimation(fab_close);
del.startAnimation(fab_close);
remake.startAnimation(fab_close);
back.startAnimation(fab_close);
copy.setClickable(false);
del.setClickable(false);
remake.setClickable(false);
back.setClickable(false);
isFabOpen = false;
} else {
tap.startAnimation(rotate_forward);
copy.startAnimation(fab_open);
del.startAnimation(fab_open);
remake.startAnimation(fab_open);
back.startAnimation(fab_open);
copy.setClickable(true);
del.setClickable(true);
remake.setClickable(true);
back.setClickable(true);
isFabOpen = true;
}
}
});
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) layout.findViewById(R.id.dialoodcontent);
TextView title = (TextView) coordinatorLayout.findViewById(R.id.title_dialogod);
title.setText(oneDayList.get(position).getTitle());
TextView content = (TextView) coordinatorLayout.findViewById(R.id.tcontent);
content.setText(oneDayList.get(position).getContent());
TextView date= (TextView)coordinatorLayout.findViewById(R.id.date);
date.setText(oneDayList.get(position).getDate());
TextView time= (TextView) coordinatorLayout.findViewById(R.id.time);
time.setText(oneDayList.get(position).getTime());
ImageView imageView = (ImageView) coordinatorLayout.findViewById(R.id.imagepart);
ImageView imageView1 = (ImageView) coordinatorLayout.findViewById(R.id.circle);
int iconResId = getActivity().getResources().getIdentifier(oneDayList.get(position).getIcon(), "drawable", getActivity().getPackageName());
imageView.setImageResource(iconResId);
GradientDrawable bgShape = (GradientDrawable) imageView1.getDrawable();
bgShape.setColor(Color.parseColor(oneDayList.get(position).getColour()));
SeekBar seekBar = (SeekBar) coordinatorLayout.findViewById(R.id.volumeSelectSeek);
seekBar.setMax(15);
seekBar.setProgress(oneDayList.get(position).getVolume());
seekBar.isSaveEnabled();
TextView realmel = (TextView) coordinatorLayout.findViewById(R.id.truemelody);
realmel.setText(oneDayList.get(position).getSound()+"("+oneDayList.get(position).getDirSound()+")");
TextView typeofs= (TextView) coordinatorLayout.findViewById(R.id.toss);
int v=oneDayList.get(position).getVibration();
if(v==1){
typeofs.setText("Vibaration");
}
int os=oneDayList.get(position).getOriginalSound();
if(os==1){
String i ="";
if(typeofs.getText().toString().isEmpty())
{
typeofs.setText("Sound");
}else{
i=typeofs.getText().toString() + " and ";
typeofs.setText(i+"Sound");
}
}
int wh=oneDayList.get(position).getWhistling();
if(wh==1){
String i ="";
if(typeofs.getText().toString().isEmpty())
{
typeofs.setText("Whistle");
}else{
i=typeofs.getText().toString() + " and ";
typeofs.setText(i+"Whistle");
}
}else{
}
myDialog.setView(layout);
myDialog.show();
//Intent intent = new Intent(getActivity().getApplicationContext(),CreateOneDayActivity.class);
// intent.putExtra("mId",oneDayList.get(position).getId());
// startActivity(intent);
}
@Override
public void onLongClick(View view, int position) {
}
}));
}else{
textView1.setText("You Haven't got any Active Tasks !");
}
FloatingActionButton fab = (FloatingActionButton) v.findViewById(R.id.fabCreateOd);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getActivity().finish();
Intent intent = new Intent(getActivity().getApplicationContext(),CreateOneDayActivity.class);
intent.putExtra("mId",1 + database.getLastIdOD());
startActivity(intent);
Snackbar.make(view, "New Task", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
return v;
}
public interface ClickListener {
void onClick(View view, int position);
void onLongClick(View view, int position);
}
public static class RecyclerTouchListener implements RecyclerView.OnItemTouchListener {
private GestureDetector gestureDetector;
private ClickListener clickListener;
public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final ClickListener clickListener) {
this.clickListener = clickListener;
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
@Override
public void onLongPress(MotionEvent e) {
View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
if (child != null && clickListener != null) {
clickListener.onLongClick(child, recyclerView.getChildPosition(child));
}
}
});
}
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
View child = rv.findChildViewUnder(e.getX(), e.getY());
if (child != null && clickListener != null && gestureDetector.onTouchEvent(e)) {
clickListener.onClick(child, rv.getChildPosition(child));
}
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
}
[MCVE]を投稿してください。人々があなたのコードを読んで、あなたの質問に答えるのを助けます。 –