android - How to configure an inner-layout programmatically -


i have layout defined in xml, looks this:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:id="@+id/footer_layout"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:orientation="horizontal">      <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_weight="1"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:gravity="center">          <!-- add views here -->                  </relativelayout>      <textview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="@string/app"/>  </linearlayout> 

i inflating inside activity, relativelayout needs have textviews depending on data application. how possibly extend , add different views in it?


note: different this question because trying figure out how extend inner-layout without using class content want add.

xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/footer_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal">  <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id=@+id/inner_layout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:gravity="center">      <!-- add views here -->              </relativelayout>  <textview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="@string/app"/>  </linearlayout> 

activity

 relativelayout relativelayout=(relativelayout) findviewbyid(r.id.inner_layout);  relativelayout.addview(//add view here(one allowed)); 

if ordering views in relativelayout use rules. better use linearlayout.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -