EditText Settext not working with Fragment

后端 未结 5 1886
花落未央
花落未央 2020-12-01 03:36

I have fragments for 3 states of a screen; Add, Edit and View. In Add, I create an entity and save it. Next time I open it in View mode and set the entity name using

5条回答
  •  孤独总比滥情好
    2020-12-01 04:13

    According to the @TusharVengrulekar , this is how you must implement your Fragment

    public class ActionBar extends Fragment {
    
    private TextView lbl_title;
    private String title;
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    
        View view = inflater.inflate(R.layout.fragment_action_bar, container, false);
        title = "Contacts";
        lbl_title = (TextView) view.findViewById(R.id.lbl_title);
    
        return view;
    }
    
    @Override
    public void onStart(){
        super.onStart();
    
        lbl_title.setText(title);
    }
    
    @Override
    public void onResume(){
        super.onResume();
    }
    }
    

提交回复
热议问题