Hello, I have a Fragment for a ViewPager:
package my.test.myapplication;
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.Button;
public class Fragment1 extends Fragment {
private Button btn;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// point A
return inflater.inflate(R.layout.frag1,container,false);
}
}
When I would add this under point A, it comes a error message:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// point A
btn = (Button) findViewById(R.id.button);
return inflater.inflate(R.layout.frag1,container,false);
}
The error message:
Cannot resolve method 'findViewById(int)'
What can I do?