Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had similar kind of screen so,you can make use of some code below.</p> <pre><code>public class ListViewCustomAdapter extends BaseAdapter { /** * Array list to hold assets which need to be displayed */ ArrayList&lt;Asset&gt; itemList; /** * Context: Interface to global information about an application * environment. */ public Activity context; /** * Layout inflater to inflate view of each row of the list from the layout * xml */ public LayoutInflater inflater; /** * @param context * : Context: Interface to global information about an * application environment. * @param itemList * : arraylist to hold asset which need to be displayed in list */ public ListViewCustomAdapter(Activity context, ArrayList&lt;Asset&gt; itemList) { super(); this.context = context; this.itemList = itemList; this.inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); } // @Override /* * (non-Javadoc) * * @see android.widget.Adapter#getCount() */ public int getCount() { if (itemList != null) { return itemList.size(); }else return 0; } // @Override /* * (non-Javadoc) * * @see android.widget.Adapter#getItem(int) */ public Object getItem(int position) { if(itemList != null){ return itemList.get(position); }else{ return 0; } } // @Override /* * (non-Javadoc) * * @see android.widget.Adapter#getItemId(int) */ public long getItemId(int position) { return 0; } /** * @author asadafale class to create view of each row in the list */ public static class ViewHolder { /** * displays name of asset */ TextView txtVw_name; /** * displays serial no of asset */ TextView txtVw_sno; /** * displays type of asset */ TextView txtVw_type; } // @Override /* * (non-Javadoc) * * @see android.widget.Adapter#getView(int, android.view.View, * android.view.ViewGroup) */ public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = inflater.inflate(R.layout.listview_row, null); holder.txtVw_name = (TextView) convertView .findViewById(R.id.tv_name); holder.txtVw_sno = (TextView) convertView.findViewById(R.id.tv_sno); holder.txtVw_type = (TextView) convertView .findViewById(R.id.tv_type); convertView.setTag(holder); } else holder = (ViewHolder) convertView.getTag(); // set selected item LinearLayout activeItem = (LinearLayout) convertView; if (position == SearchAssetActivity.selectedItem) { activeItem.setBackgroundColor(Color.GRAY); // for focus on it int top = (activeItem == null) ? 0 : activeItem.getTop(); ((ListView) parent).setSelectionFromTop(position, top); } else { activeItem.setBackgroundColor(Color.BLACK); } Asset bean = (Asset) itemList.get(position); holder.txtVw_name.setText(bean.getAssetName()); holder.txtVw_sno.setText(bean.getSno()); holder.txtVw_type.setText(bean.getAssetType()); return convertView; } } </code></pre> <p><img src="https://i.stack.imgur.com/oDdD1.png" alt="enter image description here"></p> <p>Part of my screen looks similar like what you want.</p> <p>Here's my layout in xml :</p> <pre><code>&lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/grey05" android:orientation="horizontal" &gt; &lt;TextView android:id="@+id/tv_name" android:layout_width="1dip" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_weight="0.25" android:text="Name" android:textAppearance="?android:attr/textAppearanceMedium" &gt; &lt;/TextView&gt; &lt;TextView android:id="@+id/tv_sno" android:layout_width="1dip" android:layout_height="wrap_content" android:layout_weight="0.25" android:text="Serial No." android:textAppearance="?android:attr/textAppearanceMedium" &gt; &lt;/TextView&gt; &lt;TextView android:id="@+id/tv_type" android:layout_width="1dip" android:layout_height="wrap_content" android:layout_weight="0.25" android:layout_marginLeft="20dp" android:text="Type" android:textAppearance="?android:attr/textAppearanceMedium" &gt; &lt;/TextView&gt; &lt;/LinearLayout&gt; </code></pre> <p>I knew that I want to display 3 columns only. You can have those many textview defined in your layout.xml. In your case I believe you will know number of columns on the fly so you will need some kind of an array of <code>TextView</code>s to do it dynamically which can't be done through xml. You will have to define an array of <code>TextView</code>s in your adapter class and on the fly you can initialize depending on the data coming from database. Hope you got what I wanted to convey. Let me know if you need more help designing that, once you get started. :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload