我使用Firebase开发了一个Android应用程序.并正在制作一个邮政系统.所以使用这些代码,我想点击Firebase RecyclerView中的每个项目.
我已将我的代码更改为制作可点击的项目.
变化如下.
之前,
@Override
protected void onStart() {
super.onStart();
final Query DBquery = FirebaseDatabase.getInstance().getReference().child("post").orderByChild("count");
FirebaseRecyclerAdapter<Post, PostViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Post, PostViewHolder>(
Post.class,
R.layout.post_row,
PostViewHolder.class,
DBquery
mDatabase
) {
@Override
protected void populateViewHolder(PostViewHolder viewHolder, Post model, int position) {
viewHolder.setTitle(model.getTitle());
viewHolder.setDesc(model.getDesc());
viewHolder.setImage(getApplicationContext(), model.getImage());
viewHolder.setDate(model.getDate());
}
};
mPostList.setAdapter(firebaseRecyclerAdapter);
}
public static class PostViewHolder extends RecyclerView.ViewHolder {
View mView;
public PostViewHolder(View itemView) {
super(itemView);
mView = itemView;
}
public void setTitle(String title){
TextView post_title = mView.findViewById(R.id.post_title);
post_title.setText(title);
}
public void setDesc(String …Run Code Online (Sandbox Code Playgroud) android firebase android-recyclerview firebase-realtime-database
开发商!我在C中有一个堆栈的push()方法的问题!
我在C中实现了自己的push()方法!但我无法理解结果!
我的堆栈代码如下
#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 10
int top = -1;
int array[MAX_SIZE];
void init(){
top = -1;
}
void push(int array[], int data){
if(top > MAX_SIZE-1)
fprintf(stderr, "invalid top %d\n", top+1);
else{
array[++top] = data; // top == 9, ++top == 10
printf("top: %d data: %d\n", top+1, array[top]); // top == 11, top == 10
}
}
void pop(int array[]){
}
void peek(int array[]){
}
int main() {
int data = 1;
for (int i=0; i<MAX_SIZE; …Run Code Online (Sandbox Code Playgroud) 我很好奇require()函数在Node.js中是如何工作的.
所以我在查看NodeJS核心模块中的代码.
Webstorm中nodejs项目中此文件的路径如下所示.
外部库\ Node.js Core\core-modules\internal\modules\cjs\loader.js
const {
makeRequireFunction,
requireDepth,
stripBOM,
stripShebang } = require('internal/modules/cjs/helpers');
Run Code Online (Sandbox Code Playgroud)
所以,我还没有在javascript中看到上面的变量形式.而且我发现数组中的文本是helper.js中函数的名称.
helper.js路径在下面.
外部库\ Node.js Core\core-modules\internal\modules\cjs\helper.js
// Invoke with makeRequireFunction(module) where |module| is the Module
object
// to use as the context for the require() function.
function makeRequireFunction(mod) {
const Module = mod.constructor;
function require(path) {
try {
exports.requireDepth += 1;
return mod.require(path);
} finally {
exports.requireDepth -= 1;
}
}
function resolve(request, options) {
if (typeof request !== 'string') {
throw new ERR_INVALID_ARG_TYPE('request', 'string', request); …Run Code Online (Sandbox Code Playgroud) 我正在研究C编程中的数据结构.我有一个指针问题.指针变量头有一个简单的初始化.
int* head = NULL;
Run Code Online (Sandbox Code Playgroud)
我不得不在C中研究指针的概念,现在我明白了.但,
当我使用该代码时.我无法理解如何通过值NULL分配*head.因为据我所知,变量头(不是*头)应首先具有int值.(这是整数类型的地址).
但它在该代码中没有任何价值.
所以...我的意见是......
int* head;
head = (some address here);
*head = NULL;
Run Code Online (Sandbox Code Playgroud)
这段代码对我有意义.因为head的值必须是integer类型的地址.
但仍然不知道第一个代码如何工作.
第一个代码:
int* head = NULL;
Run Code Online (Sandbox Code Playgroud)