Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>Add this row.xml to your layout folder</h3> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Header"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/text"/&gt; &lt;/LinearLayout&gt; </code></pre> <h3>make your main xml layout as this</h3> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" &gt; &lt;ListView android:id="@+id/listview" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p>This is your adapter</p> <pre><code>class yourAdapter extends BaseAdapter { Context context; String[] data; private static LayoutInflater inflater = null; public yourAdapter(Context context, String[] data) { // TODO Auto-generated constructor stub this.context = context; this.data = data; inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public int getCount() { // TODO Auto-generated method stub return data.length; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return data[position]; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub View vi = convertView; if (vi == null) vi = inflater.inflate(R.layout.row, null); TextView text = (TextView) vi.findViewById(R.id.text); text.setText(data[position]); return vi; } } </code></pre> <h3>Your java activity </h3> <pre><code>public class StackActivity extends Activity { ListView listview; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); listview = (ListView) findViewById(R.id.listview); listview.setAdapter(new yourAdapter(this, new String[] { "data1", "data2" })); } } </code></pre> <h3> the results </h3> <p><img src="https://i.stack.imgur.com/IzoOH.jpg" alt="enter image description here"></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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    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