The second parameter of the LayoutInflater.inflate
method, which you currently have set as null
, is the root of the layout you want to inflate into. Try this;
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
LayoutInflater inflator = Sale.this.getLayoutInflater();
TableRow rowView = new TableRow(v.getContext());
inflator.inflate(R.layout.activity_sale, rowView);
table_sale.addView(rowView);
}
You should also edit your xml so that it is merged into the rowView object, to avoid unnecessary additional views.
activity_sale.xml
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/my_row" >
<ImageView
android:layout_width="100dp"
android:layout_height="95dp"
android:src="@drawable/dalass"
android:layout_weight="1" />
<LinearLayout
android:orientation="vertical"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<AutoCompleteTextView
android:id="@+id/autocompletetextview"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text=""
android:inputType="numberDecimal"
android:imeOptions="flagNoExtractUi"
android:textColor="#000000" >
</AutoCompleteTextView>
<EditText
android:id="@+id/edit_sale2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:inputType="numberDecimal"
android:imeOptions="flagNoExtractUi" />
</LinearLayout>
</merge>