//Creating Views
private RecyclerView recyclerView;
private RecyclerView.Adapter adapter;
private RecyclerView.LayoutManager layoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Initializing Views
recyclerView = (RecyclerView) findViewById(R.id.post_recycler);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
//Adding adapter to recyclerview
recyclerView.setAdapter(adapter);
//Creating Views
private RecyclerView recyclerView;
private RecyclerView.Adapter adapter;
private RecyclerView.LayoutManager layoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Initializing Views
recyclerView = (RecyclerView) findViewById(R.id.post_recycler);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Initializing Views
recyclerView = (RecyclerView) findViewById(R.id.post_recycler);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
//Initializing the postlist list
mPostItemsList = new ArrayList<>();
//Caling method to get data
getData();
//This method will get data from the web api
private void getData(){
//Showing progress dialog
final ProgressDialog progressDialog = ProgressDialog.show(this, "Loading posts", "Please wait", false, false);
//Creating a json request
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(ConfigPost.GET_URL,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
//Dismissing the progress dialog
progressDialog.dismiss();
//calling method to parse json array
parseData(response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
//Creating request queue
RequestQueue requestQueue = Volley.newRequestQueue(this);
//Adding request to the queue
requestQueue.add(jsonArrayRequest);
}
//This method will parse json data
private void parseData(JSONArray array){
for(int i = 0; i<array.length(); i++) {
PostItems postItem = new PostItems();
JSONObject jsonObject = null;
try {
jsonObject = array.getJSONObject(i);
postItem.setPost_image(jsonObject.getString(ConfigPost.TAG_POST_IMAGE));
postItem.setPost_title(jsonObject.getString(ConfigPost.TAG_POST_TITLE));
postItem.setPost_body(jsonObject.getString(ConfigPost.TAG_POST_BODY));
} catch (JSONException w) {
w.printStackTrace();
//Toast.makeText(this, "Error in parsing Json", Toast.LENGTH_LONG).show();
}
mPostItemsList.add(postItem);
}
//Finally initialing the adapter
adapter = new PostAdapter(mPostItemsList, this);
//Adding adapter to recyclerview
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
public class PostAdapter extends RecyclerView.Adapter<PostAdapter.ViewHolder>{
private ImageLoader mImageLoader;
private Context mContext;
//List of posts
List<PostItems> mPostItems;
public PostAdapter(List<PostItems> postItems, Context context) {
super();
//Getting all Posts
this.mPostItems = postItems;
this.mContext = context;
}
@Override
public ViewHolder onCreateViewHolder (ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.post_summ, parent, false);
ViewHolder viewHolder = new ViewHolder(v);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
PostItems postList = mPostItems.get(position);
mImageLoader = VolleyRequest.getInstance(mContext).getImageLoader();
mImageLoader.get(postList.getPost_image(), ImageLoader.getImageListener(holder.postImage, R.mipmap.ic_launcher, android.R.drawable.ic_dialog_alert));
holder.postImage.setImageUrl(postList.getPost_image(), mImageLoader);
holder.postTitle.setText(postList.getPost_title());
holder.postBody.setText(postList.getPost_body());
}
@Override
public int getItemCount(){
//Return the number of items in the data set
return mPostItems.size();
}
class ViewHolder extends RecyclerView.ViewHolder {
public NetworkImageView postImage;
public TextView postTitle;
public TextView postBody;
public ViewHolder(View postView) {
super(postView);
postImage = (NetworkImageView) postView.findViewById(R.id.post_image);
postTitle = (TextView) postView.findViewById(R.id.post_title);
postBody = (TextView) postView.findViewById(R.id.post_body);
}
}
}
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.jadebyte.geekng.MainActivity"
tools:showIn="@layout/app_bar_main">
<android.support.v7.widget.RecyclerView
android:id="@+id/post_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
</RelativeLayout>
知道是什么引起的吗?
我想从火力点实时数据库显示图片。(带有加密图像(字符串))类似加密图像是“照片” 函数loadPhoto() 问题出在哪里?我连接adapter和recyclerview,并设置GridManager。
ListPetientFragment。JAVA 错误是:2021-11-17 18:41:02.417 29997-29997/?E/rtphonemedicat:运行时设置的未知位_标志:0x8000 2021-11-17 18:41:03.628 29997-30029/com。尼戈特。smartphonemedicate E/GED:无法获取GED日志Buf,错误(0)2021-11-17
这是我在片段中的代码: 这是从LogCat得到的 没有连接适配器跳过布局 观赏者 我在model类中设置getter和setter方法。(holder类所必需变量)
我正在尝试在片段中使用回收器视图,但我遇到一个问题,我的列表没有出现,我有这个错误: e/recycle view:未连接适配器;跳过布局 我检查了解决方案,显然问题出现在: > < li > < p > RecyclerView在适配器后初始化 绑定和设置回收器在“创建”查看“而不是”创建“中查看 但我注意到了,我尝试了其他选择,我仍然面临着同样的问题。 这是我的片段代码: XML: 列表适配器
我制作了一个基本的购物清单应用程序,它利用回收器视图来显示列表项目。我正在尝试使用带有片段的导航添加设置屏幕。我遇到了我的回收器视图的问题 主活动.kt HomeFragment.kt 设置Fragment.kt activity_main.xml fragment\u home.xml navigation.xml 不确定是否需要更多信息。提前道歉-我是android studio的新手
当应用程序启动时,我得到一个空白屏幕,当我检查日志时,我得到:E/回收人员视图:没有连接适配器;跳过布局错误 我不知道为什么?任何想法,它似乎没有附加回收器视图或添加任何数据,我附加了Main活动、DataAdapter和数据类。 主要活动 数据适配器 下面是我的数据类,将从中提取数据 我ncluded.java 收集器和设置器 这是jsonResponse类,在接口中引用 感谢任何帮助。