【发布时间】:2016-07-16 16:46:04
【问题描述】:
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);
}
编译器显示错误:找不到符号方法 setText(String) 并且无法解析方法 setText(java.lang.String)。
请有人告诉我如何解决这个问题
【问题讨论】:
-
将
topMemeText和bottomMemeText声明为TextView而不是View,因为setText方法在TextView中,而不是在TextView 的超类(视图)中 -
移除 View 并改用 TextView
-
是的,这是遗漏的部分,问题已解决,谢谢@ρяσѕρєяK
-
是的,这是遗漏的部分,问题已解决,谢谢@Tapanparmar