I want to add a view comprising of 4 buttons and a textview to a linear layout and set that newly made view to a viewflipper...Client's requirement is that i need to create the layout the programmatically and not using an xml file
See this is sample code, this might helpful for you. Instaed of LockView you can mention other views..
lockLayout = (LinearLayout) findViewById(R.id.quick_lock_layout);
private void renderLockLayout() {
lockLayout.removeAllViews();
lockLayout.invalidate();
lockLayout.setLayoutParams(new LinearLayout.LayoutParams(
lockLayoutWidth + 7, (height / 6)));
/*
* Toast.makeText(ApplicationContext.getContext(), "Num count is :" +
* _totalLocks, Toast.LENGTH_SHORT).show();
*/
Log.i(getClass().getSimpleName(), "Total :" + _totalLocks);
lockViewArray = new LockView[_totalLocks];
for (int index = 0; index < _totalLocks; index++) {
LockView lockview = (LockView) inflater.inflate(R.layout.lockview,
null);
lockview.setLayoutParams(new LayoutParams((width),
LayoutParams.WRAP_CONTENT));
lockLayout.addView(lockview);
lockViewArray[index] = lockview;
}
lockLayout.invalidate();
}