Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>this would be the view that is used for each cell </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Left side" android:layout_alignParentLeft="true"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Right side" android:layout_alignParentRight="true"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>this is an example since i have no idea where your knowledge is at with lists, if the above xml was called "temp.xml" you would use this in the setlistadapter function</p> <pre><code> import android.app.ListActivity; import android.os.Bundle; import android.widget.ArrayAdapter; public class FooList extends ListActivity extends BaseAdapter { String[] listItems = {"item 1", "item 2 ", "list", "android", "item 3", "foobar", "bar", }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_with_listview); // implement your own adapter } } public View getView(int position, View convertView, ViewGroup parent) { // A ViewHolder keeps references to children views to avoid unneccessary calls // to findViewById() on each row. ViewHolder holder; // When convertView is not null, we can reuse it directly, there is no need // to reinflate it. We only inflate a new View when the convertView supplied // by ListView is null. if (convertView == null) { convertView = mInflater.inflate(R.layout.temp, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder = new ViewHolder(); holder.left = (TextView) convertView.findViewById(R.id.left); holder.right = (TextView) convertView.findViewById(R.id.right); convertView.setTag(holder); } else { // Get the ViewHolder back to get fast access to the TextView // and the ImageView. holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.left.setText("left text"); holder.right.setText("right text"); return convertView; } class ViewHolder { public TextView left; public TextView right; } </code></pre>
 

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