不能从静态上下文中引用任何静态方法“getContext()”

穆罕默德·加扎利

我在 'getContext()' 方法中有问题是不可接受的并且不起作用,并且同一行中的 'ViewGroup' 是“Expression expected”这是一些代码:

从我的模块应用程序

我的库版本

    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); 

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

不能从静态上下文中引用

通知`notify()`不能从静态上下文中引用

试图让我的显示方法工作(不能从静态上下文中引用非静态方法)

非静态方法不能从静态上下文中引用

非静态方法不能从静态上下文中引用

非静态方法getIntent()不能从静态上下文中引用

不能从静态上下文中引用非静态方法 matcher(CharSequence)

的java - 非静态方法“getLogger”不能从静态上下文中引用

非静态方法count(int)不能从静态上下文中引用

非静态方法不能从静态上下文中的java 8流引用

JAVA - 不能从静态上下文中引用非静态方法 add(E)

非静态方法<T> findViewById(int)不能从静态上下文中引用

不能从静态上下文中引用非静态方法“inflate(byte[],int,int)”

非静态方法readData(GoogleApiClient,DataReadRequest)不能从静态上下文中引用

不能从静态上下文中引用非静态方法 getSocketFactory

非静态变量s不能从静态上下文中引用

非静态变量,不能从静态上下文中引用

“不能从静态上下文中引用的非静态变量”?

非静态类不能从静态上下文中引用

java:不能从静态上下文中引用非静态变量错误

java:非静态变量,不能从静态上下文中引用

不能从静态上下文中引用非静态变量 [JAVA]

非静态edit()不能从静态上下文中引用

不能从静态上下文中引用非静态 setGravity

不能从静态上下文中引用非静态变量?

非静态变量 this 不能从静态上下文中引用 Dormitory dormitory = new Dormitory();

为什么字符串::工作的isEmpty当非静态方法不能从静态上下文中引用?

非静态方法'getSharedPreferences(java.lang.String,int)'不能从静态上下文中引用

如果生成了外部类,则不能从静态上下文中引用“ Main.this”