i hope you are fine. im new in java, and what i want is to add any view, i determine it using java code only, i did that in dialog, i added edit text to alert dialog using this code :
AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this, AlertDialog.THEME_TRADITIONAL);
alert.setTitle("Title");
final EditText myedit = new EditText(MainActivity.this);
myedit.setHint("Type something");
myedit.setLayoutParams
(new LinearLayout.LayoutParams
(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT,
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
final AlertDialog dialog = alert.create();
dialog.show();
and this work 100% with me, i got edittext in the Dialog, like this :
and now i can't get another view by using this way in the MainActivity view:
for example this code here i tried it without get anything :
final LinearLayout linear1 = new LinearLayout(this);
linear1.setOrientation(LinearLayout.HORIZONTAL);
linear1.setBackgroundColor(Color.white);
LinearLayout.LayoutParams layoutForInner = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
linear1.setLayoutParams(layoutForInner);
final ListView listview1 = new ListView(this);
listview1.setLayoutParams
(new LinearLayout.LayoutParams
(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT,
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
linear1.addView(listview1);
please Help me solving this, if it is not possible please give me alternative to this way, for adding/creating views from .java only without need .xml