我在'getContext()'方法中遇到问题,这是不可接受的,并且不起作用,并且同一行中的'ViewGroup'是“期望的表达” 这是一些代码:
通过“我的模块”应用
我的图书馆版本
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-database:19.1.0'
implementation 'com.firebaseui:firebase-ui-storage:4.3.1'
implementation 'com.google.firebase:firebase-storage:19.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.firebaseui:firebase-ui-database:2.1.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'de.hdodenhof:circleimageview:3.0.1'
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
我的代码:
FirebaseRecyclerAdapter<Posts, PostsViewHolder> firebaseRecyclerAdapter =
new FirebaseRecyclerAdapter<Posts, PostsViewHolder>() {
@Override
protected void onBindViewHolder(@NonNull PostsViewHolder holder, int position, @NonNull Posts model) {
}
@NonNull
@Override
public PostsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(ViewGroup.getContext()).inflate(R.layout.all_posts_layout,ViewGroup, false);
public PostsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(ViewGroup.getContext()).inflate(R.layout.all_posts_layout ,ViewGroup, false);
PostsViewHolder viewHolder = new PostsViewHolder(view);
return viewHolder;
}
};
}
} ```
答案 0 :(得分:0)
View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.all_posts_layout, parent, false);