Skip to content Skip to sidebar Skip to footer

Text Isn't Showing After Using Settext() To Textview() In Inflated Layout

Yes, I know that similar questions were asked before but I tried many of those. So I have a problem with setting text in TextView in the inflated layout. I tried setContentView() t

Solution 1:

Thanks for comments! Problem is solved!

public void bodAlg() {
    LayoutInflater inflater = (LayoutInflater) 
    getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View vi = inflater.inflate(R.layout.layout1,  null);  

    EditText editText = (EditText) vi.findViewById(R.id.bod_servers);
    String[] serversArray = editText.getText().toString().split(", ");

    TextView textView = (TextView) vi.findViewById(R.id.bod_serv_array);
    textView.setText(Arrays.toString(serversArray));

    // solution 
    CoordinatorLayout mainL = (CoordinatorLayout) findViewById(R.id.main_view);
    mainL.removeAllViews(); // remove previous view, add 2nd layout
    mainL.addView(vi);
}

Post a Comment for "Text Isn't Showing After Using Settext() To Textview() In Inflated Layout"