我的应用程序正在正确地从parse.com获取信息,但没有像以前那样在recyclerview中正确地显示信息。系统提示我错误消息“no adapter attached;skipping layout”,并且recyclerview仍然为空。请你检查一下我的程序并通知我任何我可能错过的错误好吗?
$
package com.example.jbobo_000.prac;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import com.parse.FindCallback;
import com.parse.GetCallback;
import com.parse.Parse;
import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import java.util.ArrayList;
import java.util.List;
public class HomeScreen extends AppCompatActivity {
private RecyclerView mRecyclerDrawer;
private customAdapter mAdapter;
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_screen);
setupDrawer();
context=this;
final List<Information> data = new ArrayList<>();
Parse.initialize(this, "XXXXXXXXXXXXXXX", "XXXXXXXXXXXXX");
ParseQuery<ParseObject> query = ParseQuery.getQuery("flyerDataFetch");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> results, com.parse.ParseException e) {
if (e == null) {
for (ParseObject a : results) {
Information information = new Information();
information.partyName = a.getString("partyName");
information.partyPromoterName = a.getString("partyPromoterName");
information.partyCost = a.getString("partyCost");
// information.flyerPic = a.getParseFile("partyFlyerImage");
//information.partyPromoterPic = a.getParseFile("partyFlyerImage");
data.add(information);
}
} else {
// something went wrong
}
mRecyclerDrawer = (RecyclerView) findViewById(R.id.drawerList);
mRecyclerDrawer.setLayoutManager(new LinearLayoutManager(context));
mAdapter = new customAdapter(getApplicationContext(), data);
mRecyclerDrawer.setAdapter(mAdapter);
mAdapter.notifyDataSetChanged();
}
});
}
private void setupDrawer() {
Toolbar mToolbar;
NavigationDrawer mDrawerFragment;
mToolbar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//setup the NavigationDrawer
mDrawerFragment = (NavigationDrawer)
getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
mDrawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
}
$
package com.example.jbobo_000.prac;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.parse.ParseImageView;
import java.util.Collections;
import java.util.List;
public class customAdapter extends RecyclerView.Adapter<customAdapter.MyViewHolder> {
List<Information> data = Collections.emptyList();
private LayoutInflater inflater;
private Context context;
public customAdapter (Context context,List<Information>data){
this.context=context;
inflater=LayoutInflater.from(context);
this.data= data;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
View view= inflater.inflate(R.layout.custom_row, parent, false);
MyViewHolder holder = new MyViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(MyViewHolder holder,int position){
Information current= data.get(position);
holder.promoterNameText.setText(current.partyPromoterName);
holder.costText.setText(current.partyCost);
holder.partyNameText.setText(current.partyName);
holder.flyerImage.setParseFile(current.flyerPic);
holder.promoterImage.setParseFile(current.partyPromoterPic);
}
@Override
public int getItemCount(){
return data.size();
}
class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView promoterNameText;
TextView costText;
TextView partyNameText;
ParseImageView flyerImage;
ParseImageView promoterImage;
public MyViewHolder(View itemView) {
super(itemView);
itemView.setOnClickListener(this);
promoterImage = (ParseImageView) itemView.findViewById(R.id.promoterPicImage);
flyerImage = (ParseImageView) itemView.findViewById(R.id.flyertImage);
costText = (TextView) itemView.findViewById(R.id.costText);
promoterNameText = (TextView) itemView.findViewById(R.id.promoterNameText);
partyNameText = (TextView) itemView.findViewById(R.id.partyNameText);
}
@Override
public void onClick(View v) {
context.startActivity(new Intent(context, partyInformation.class));
}
}
}
$
06-16 16:42:35.119 2230-2230/? I/art﹕ Late-enabling -Xcheck:jni
06-16 16:42:35.261 2230-2230/? D/CrashReporting﹕ Crash reporting is enabled for com.example.jbobo_000.prac, initializing...
06-16 16:42:35.292 2230-2230/? D/CrashReporting﹕ Looking for error files in /data/data/com.example.jbobo_000.prac/files/com.parse/cr/reports
06-16 16:42:35.296 2230-2230/? D/CrashReporting﹕ Looking for error files in /data/data/com.example.jbobo_000.prac/files/com.parse/cr/minidumps
06-16 16:42:35.484 2230-2260/? D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-16 16:42:35.488 2230-2230/? D/﹕ HostConnection::get() New Host Connection established 0xb3ec9ac0, tid 2230
06-16 16:42:35.498 2230-2230/? D/Atlas﹕ Validating map...
06-16 16:42:35.554 2230-2260/? D/libEGL﹕ loaded /system/lib/egl/libEGL_emulation.so
06-16 16:42:35.555 2230-2260/? D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_emulation.so
06-16 16:42:35.568 2230-2260/? D/libEGL﹕ loaded /system/lib/egl/libGLESv2_emulation.so
06-16 16:42:35.579 2230-2260/? D/﹕ HostConnection::get() New Host Connection established 0xaf0395c0, tid 2260
06-16 16:42:35.600 2230-2260/? I/OpenGLRenderer﹕ Initialized EGL, version 1.4
06-16 16:42:35.655 2230-2260/? D/OpenGLRenderer﹕ Enabling debug mode 0
06-16 16:42:35.676 2230-2260/? W/EGL_emulation﹕ eglSurfaceAttrib not implemented
06-16 16:42:35.676 2230-2260/? W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xaf035b40, error=EGL_SUCCESS
06-16 16:42:37.786 2230-2230/com.example.jbobo_000.prac I/ViewUtils﹕ app:theme is now deprecated. Please move to using android:theme instead.
06-16 16:42:38.132 2230-2260/com.example.jbobo_000.prac W/EGL_emulation﹕ eglSurfaceAttrib not implemented
06-16 16:42:38.132 2230-2260/com.example.jbobo_000.prac W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xb3edd980, error=EGL_SUCCESS
06-16 16:42:38.167 2230-2230/com.example.jbobo_000.prac E/RecyclerView﹕ No adapter attached; skipping layout
06-16 16:42:38.524 2230-2230/com.example.jbobo_000.prac E/RecyclerView﹕ No adapter attached; skipping layout
06-16 16:42:40.723 2230-2230/com.example.jbobo_000.prac D/AndroidRuntime﹕ Shutting down VM
06-16 16:42:40.724 2230-2230/com.example.jbobo_000.prac E/CrashReporting﹕ ParseCrashReporting caught a AndroidRuntimeException exception for com.example.jbobo_000.prac. Building report.
06-16 16:42:40.725 2230-2230/com.example.jbobo_000.prac E/CrashReporting﹕ Handling exception for crash
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at android.app.ContextImpl.startActivity(ContextImpl.java:1246)
at android.app.ContextImpl.startActivity(ContextImpl.java:1233)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:323)
at com.example.jbobo_000.prac.customAdapter$MyViewHolder.onClick(customAdapter.java:72)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
06-16 16:42:40.725 2230-2230/com.example.jbobo_000.prac D/CrashReporting﹕ Generating report file for crash
06-16 16:42:40.794 2230-2230/com.example.jbobo_000.prac D/CrashReporting﹕ Retrieving logcat output...
06-16 16:42:40.809 2230-2230/com.example.jbobo_000.prac D/CrashReporting﹕ Retrieving logcat output...
06-16 16:42:40.827 2230-2230/com.example.jbobo_000.prac D/CrashReporting﹕ Retrieving logcat output...
06-16 16:42:40.885 2230-2230/com.example.jbobo_000.prac W/Settings﹕ Setting stay_on_always has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
06-16 16:42:41.051 2230-2230/com.example.jbobo_000.prac V/CrashReporting﹕ About to start ReportSenderWorker from #handleException
06-16 16:42:41.055 2230-2326/com.example.jbobo_000.prac D/CrashReporting﹕ #checkAndSendReports - start
06-16 16:42:41.056 2230-2326/com.example.jbobo_000.prac D/CrashReporting﹕ Looking for error files in /data/data/com.example.jbobo_000.prac/files/com.parse/cr/reports
06-16 16:42:41.057 2230-2326/com.example.jbobo_000.prac D/CrashReporting﹕ Loading file 1434487360725-AndroidRuntimeException-1.stacktrace
06-16 16:42:41.063 2230-2326/com.example.jbobo_000.prac I/CrashReporting﹕ Sending file 1434487360725-AndroidRuntimeException-1.stacktrace
06-16 16:42:41.063 2230-2326/com.example.jbobo_000.prac D/CrashReporting﹕ Sending crash report to Parse...
06-16 16:42:41.070 2230-2326/com.example.jbobo_000.prac D/CrashReporting﹕ #checkAndSendReports - finish
06-16 16:42:41.153 2230-2230/com.example.jbobo_000.prac E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.jbobo_000.prac, PID: 2230
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
at android.app.ContextImpl.startActivity(ContextImpl.java:1246)
at android.app.ContextImpl.startActivity(ContextImpl.java:1233)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:323)
at com.example.jbobo_000.prac.customAdapter$MyViewHolder.onClick(customAdapter.java:72)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
您的错误日志中没有错误:没有连接适配器;跳过布局
仅:Android.util.AndroidRuntimeException:从activity上下文外部调用startActivity()需要FLAG_ACTIVITY_NEW_TASK标志。这真的是你想要的吗?
为了避免这种情况,只需改变:
mAdapter = new customAdapter(getApplicationContext(), data);
至
mAdapter = new customAdapter(this, data);
我一直在stackoverflow和这篇博文上阅读不同的答案,并试图实现它们的解决方案,但我仍然得到错误: 片段中的布局: 和项目的布局: 我做错了什么? 编辑:以下是适配器:
我收到以下错误:“RecyclerView:未附加适配器;跳过布局”但我已附加适配器...我试过很多不同的方法,但都解决不了这个错误。 我正在使用Volley库获取数据。当我启动activity时,直到结束只有进度条可见,并且收到上面的Logcat消息。我已经在中添加了带有适配器的。你能帮帮我吗? 下面是我的代码: 主要活动 地震适配器 mainactivity.xml EquestakerAw.
我在logcat:e/recyclerview:No adapter attached中不断收到这个消息;跳过布局 到目前为止,我在StackOverflow上搜索了很长时间,但答案似乎对我不起作用。在我看来,适配器的设置是正确的。我试图在Android中实现一个应用程序的Messenger功能。 我会把代码贴在下面。 任何关于如何处理这件事的想法。
我正在使用一个片段来查看一个RecyclerView。但我总是犯这个错误 E/RecyclerView:未附加适配器;跳过布局 我已经为我的recyclerview创建了一个适配器,但布局没有显示。php后端运行良好。谁能帮帮我。下面是我的片段和适配器代码 Tips.java TipAdapter.java
我已经提到了相当少的帖子关于这个错误,但没有一个能够解决我的问题。我有一个片断,在这里我使用修改获得了我的值,我已经在下面显示了: 下面是我的RecyclerView适配器类:
一切正常。但Logcat中显示了一些错误。 E/RecyclerView:未附加适配器;跳过布局 E/RecyclerView:未附加适配器;跳过布局 我的activity代码: 我读过与同一问题有关的其他问题,但都没有帮助。请帮帮我