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

compiler showserror: cannot find symbol method setText(String) and cannot resolve method setText(java.lang.String).

pls could some one let me know how to solve this problem

4
  • 2
    Declare topMemeText and bottomMemeText as TextView instead of View because setText method is in TextView instead of in super class(View) of TextView Commented Jul 16, 2016 at 16:47
  • remove View and use TextView instead Commented Jul 16, 2016 at 16:50
  • Yes this was the missed part, problem resolved, thank you @ρяσѕρєяK Commented Jul 16, 2016 at 20:00
  • Yes this was the missed part, problem resolved, thank you @Tapanparmar Commented Jul 16, 2016 at 20:00

2 Answers 2

1

You have declared the TextView's as View, change these lines:

private static View topMemeText;
private static View bottomMemeText;

to :

private static TextView topMemeText;
private static TextView bottomMemeText;
Sign up to request clarification or add additional context in comments.

1 Comment

Yes this was the missed part, problem resolved, thank you
0

Just change the View to TextView as setText() method is use for TextViews and not for Views, Gradle can not find the appropriate method you are trying to call so it's your problem. Just try to declare components as they are and avoid Parent class declarations such as Views.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.