В XML-файле я создаю TextView. Чем я хочу добавить в операцию из кодаОшибка добавления TextView
<TextView
android:id="@+id/letter_cell"
android:gravity="center"
android:layout_weight="1"
android:text="1"
/>
MainActivity
LayoutInflater inflater = (LayoutInflater)getSystemService (Context.LAYOUT_INFLATER_SERVICE);
View table_pattern = inflater.inflate(R.layout.letters_table, null);
TextView txt_row = (TextView) table_pattern.findViewById(R.id.letter_cell);
LinearLayout linLayout = new LinearLayout(this);
linLayout.setOrientation(LinearLayout.VERTICAL);
LayoutParams linLayoutParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
setContentView(linLayout, linLayoutParam);
linLayout.addView(txt_row);
После приложения запустить я получаю ошибку
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.