-3
我有這樣一段代碼在一個片段,但它說不能解析方法findViewByIdfindViewById沒有解決
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View fragmentLayout = inflater.inflate(R.layout.fragment_note_detail, container, false);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
}
你需要給根視圖:fragmentLayout .findViewById(..); – Chol
使用fragmentLayout.findViewById(); –