gpt4 book ai didi

java - 无静态方法 'getContext()' 无法从静态上下文中引用

转载 作者:行者123 更新时间:2023-12-02 00:22:39 25 4
gpt4 key购买 nike

我在“getContext()”方法中遇到问题,该方法 Not Acceptable 并且不起作用,并且同一行中的“ViewGroup”是“预期表达式”这是一些代码:

来 self 的模块应用

我的库版本

    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;


}
};
}
} ```

最佳答案

View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.all_posts_layout, parent, false); 

关于java - 无静态方法 'getContext()' 无法从静态上下文中引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58072363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com