i am calling fragment from custom dialog. but i cant call fragment. my onClick calling function
public void text_noteClick(View v){
Fragment fragments = new Text_Note_Fragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.layout.note_text, fragments);
transaction.addToBackStack(null);
Toast.makeText(getApplicationContext(),"text",Toast.LENGTH_SHORT).show();
}
Toast is works successfully. Text_Note_Fragment class is
public class Text_Note_Fragment extends Fragment {
public Text_Note_Fragment() {
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view;
view = inflater.inflate(R.layout.note_text,container,false);
return view;
}
} i think problem is Fragment replacing function. sorry for my English :) TNX
I guess this line is the root cause.
I see you use
R.layout.note_text
inonCreateView
function, that's the layout xml for your fragment. but why you use it in replace function? you should use a container(often a FrameLayout), like this.