Currently trying to add a layout (box.xml) to my main layout (activity_main.xml) from a different activity, but having trouble correctly doing this. Here is an example of what I'm trying to do:
(Note: removed params for simplicity)
activity_main.xml
<FrameLayout>
<ScrollView>
<LinearLayout>
<!--include layout="@layout/box"-->
</LinearLayout>
</ScrollView>
</FrameLayout>
box.xml
<TableLayout>
<TableRow>
<TextView/>
<ImageView/>
</TableRow>
<TableRow>
<TextView/>
<Button/>
</TableRow>
</TableLayout>
CreateNewBoxActivity.java
(Note: My MainActivity.java calls startActivity(new Intent(this, CreateNewBoxActivity.class)))
public class CreateNewBoxActivity extends Activity {
private ImageButton mFinish;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_newBox);
mFinish = (ImageButton) findViewById(R.id.btn_finish);
mFinish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
//add box.xml where <include layout> is located in activity_main.xml
finish(); //close this activity and back to main activity to see
//added box layout
}
});
...
}
}
Thanks for any help on how to add this layout! Not sure the best way to tackle this.