package com.example.grghajj1.memecreator1;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class BottomPictureFragment extends Fragment {
private static View topMemeText;
private static View bottomMemeText;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.bottom_picture_fragment, container, false);
topMemeText = (TextView)view.findViewById(R.id.topMemeText);
bottomMemeText = (TextView)view.findViewById(R.id.bottomMemeText);
return view;
}
public void setMemeText(String top, String bottom){
topMemeText.setText(top);
bottomMemeText.setText(bottom);
}
编译器showserror:找不到符号方法setText(String)并且无法解析方法setText(java.lang.String)。
请有人告诉我如何解决这个问题
答案 0 :(得分:1)
您已将TextView声明为View,请更改以下行:
private static View topMemeText;
private static View bottomMemeText;
到:
private static TextView topMemeText;
private static TextView bottomMemeText;
答案 1 :(得分:0)
只需将查看更改为 TextView ,因为setText()方法用于TextViews而不用于视图,Gradle无法找到您尝试调用的相应方法这是你的问题。只是尝试按原样声明组件,并避免使用诸如Views之类的Parent类声明。