@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        viewRoot =  inflater.inflate(R.layout.fragment_messages, container, false);
        RelativeLayout relativeLayout = (RelativeLayout) viewRoot.findViewById(R.id.msg_fragment);
    final RadioGroup radioGroup = (RadioGroup) viewRoot.findViewById(R.id.radio_grp);
    final RadioButton rb2 = (RadioButton) viewRoot.findViewById(R.id.rb_msg2);
    final RadioButton rb3 = (RadioButton) viewRoot.findViewById(R.id.rb_msg3);
    final RadioButton rb4 = (RadioButton) viewRoot.findViewById(R.id.rb_msg4);

    final EditText editText = (EditText) viewRoot.findViewById(R.id.et_customMsg);
    final RadioButton rb1 = (RadioButton) viewRoot.findViewById(R.id.rb_msg1);
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.rb_msg1){
                str_rbText = rb1.getText().toString();
                editText.setVisibility(View.INVISIBLE);
                editText.setText("");
                Log.e("RadioButton1 Text", str_rbText);
            } else if (checkedId == R.id.rb_msg2){
                str_rbText = rb2.getText().toString();
                editText.setVisibility(View.INVISIBLE);
                editText.setText("");
            } else if (checkedId == R.id.rb_msg3){
                str_rbText = rb3.getText().toString();
                editText.setVisibility(View.INVISIBLE);
                editText.setText("");
            } else if (checkedId == R.id.rb_msg4){
                str_rbText = rb4.getText().toString();
                editText.setVisibility(View.INVISIBLE);
                editText.setText("");
            } else if (checkedId == R.id.rb_customMsg){
                    editText.setVisibility(View.VISIBLE);
                    str_rbText = editText.getText().toString().trim();
                    //editText.setBackgroundDrawable(null);  //to remove underline of EditText
                    Log.e("RadioButton 5", str_rbText);
            }
        }
    });
    Button btnSet = (Button) viewRoot.findViewById(R.id.btn_set_msgFrag);
    btnSet.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(getContext(), "Set", Toast.LENGTH_SHORT).show();
            //Log.e("Selected Msg",str_rbText);
        }
    });

    return viewRoot;
}[Java Code][1]
1

There are 1 answers

0
Francis Nduba Numbi On

Your logcat talks about a textView. But your code snippet has no TextView in it!! Aren't you leaving something out!

Your editText, I think it is better you start by setText("") before rendering it invisible.