@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]
答案 0 :(得分:0)
您的logcat谈到textView
。但是你的代码片段里面没有TextView !! Aren你没有留下任何东西!
您的editText
,我认为最好先让setText("")
开始,然后再将其隐藏起来。