I'm new to the android world. I have a xml layout that i want to add as child to other xml file's scrollview.
This is the layout[ offerview.xml ] to be inserted multiple times is -

The xml[activity_offer.xml] into which it has to be inserted is -

Java Code of the activity is -
public class OfferActivity extends Activity {
private static final String name = "Reebok";
private static final String content = "50% off on Reebok Shoes at Reliance Mart";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_offer);
View v = LayoutInflater.from(getApplicationContext()).inflate(R.layout.offerview, null);
TextView offerItemTextView = (TextView) v.findViewById(R.id.offerItemTextView);
offerItemTextView.setText(name);
TextView offerContentTextView = (TextView) v.findViewById(R.id.offertextView);
offerContentTextView.setText(content);
ImageView offerImage = (ImageView) v.findViewById(R.id.offerImageView);
offerImage.setBackgroundResource(R.drawable.ps);
((LinearLayout) findViewById(R.id.offersLayout)).addView(v);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.offer, menu);
return true;
}
}
At the moment i was just trying to include view only one time. The app crashed.


I've been stuck forever on this.