Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set adapter in case of multiple textviews per listview?
    primarykey
    data
    text
    <p>I have a multiple <code>TextView</code>s per list item in my <code>ListView</code>. I've learned to write a proper <code>getView</code> method I believe but I'm not sure ho do I use <code>setAdapter</code> to call that method. </p> <pre><code>private static String[] project = {"proj1","proj2"}; private static String[] workRequests = {"requirement gathering", "design"}; private static String[] startDate = {"02/21/2012","07/15/2011"}; private static String[] status = {"WIP","DONE"}; ListView mListView; public class MyDashboardActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mydashboard); final LayoutInflater mInflater = LayoutInflater.from(this); mListView = (ListView)findViewById(R.id.dashboardList); mListView.setAdapter( // How do I set the adapter? ); } public View getView(int position, View convertView, ViewGroup parent) { System.out.println("enters"); if(convertView == null){ convertView = LayoutInflater.from(this).inflate(R.layout.mydashboard,null); } ((TextView) convertView.findViewById(R.id.project)).setText(project[position]); ((TextView) convertView.findViewById(R.id.work_request)).setText(workRequests[position]); ((TextView) convertView.findViewById(R.id.start_date)).setText(startDate[position]); ((TextView) convertView.findViewById(R.id.status)).setText(status[position]); return convertView; } </code></pre> <p>This is the xml layout:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/home_root" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;!-- Include Action Bar --&gt; &lt;include layout="@layout/actionbar_layout" /&gt; &lt;ListView android:id="@+id/dashboardList" style="@style/LeftHeaderText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:background="@drawable/innerdashboard_bg" android:textColor="@color/textColor" &gt; &lt;TextView android:id="@+id/project" /&gt; &lt;TextView android:id="@+id/work_request" /&gt; &lt;TextView android:id="@+id/start_date" /&gt; &lt;TextView android:id="@+id/status" /&gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p>I've tried a few ways, none of which worked. Could anyone please suggest how to set the adapter in this case? Thanks!</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.
 

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