Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Chronometer in ListView Row?
    text
    copied!<p>I got a row xml for my ListView with chronometer</p> <hr> <pre><code>&lt;LinearLayout android:layout_width="fill_parent" android:id="@+id/layout_orders_list_row_ll_Timer" android:focusable="false" android:layout_height="wrap_content" android:gravity="center_horizontal|right" android:layout_gravity="center"&gt; &lt;Chronometer android:text="@+id/Chronometer01" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/layout_orders_list_row_chr_Timer" android:focusable="false" android:focusableInTouchMode="false" android:layout_gravity="center" android:enabled="true"&gt; &lt;/Chronometer&gt; &lt;Button android:background="@drawable/check" android:layout_height="wrap_content" android:id="@+id/layout_orders_list_row_bt_Done" android:layout_width="wrap_content" android:focusable="false" android:onClick="OnRowButtonClick"&gt; &lt;/Button&gt; </code></pre> <p></p> <hr> <p>and I want to start my chronometer for each row.I'm getting data from database and fill the adapter.After that I'm connecting to each chronometer and trying to calculate it.But it doesn't work.</p> <pre><code> SimpleAdapter simpleAdapter = new SimpleAdapter(this, fillMaps, R.layout.orders_list_row, from, to); listView.setAdapter(simpleAdapter); for (int i = 0; i &lt; simpleAdapter.getCount(); i++) { LinearLayout vwParentRow = (LinearLayout) simpleAdapter.getView(i, null, null); LinearLayout ChildTop = (LinearLayout) vwParentRow.getChildAt(0); LinearLayout ChildTop2 = (LinearLayout) ChildTop.getChildAt(1); final Chronometer chrono = (Chronometer) ChildTop2.getChildAt(0); chrono.setText("00:00:00"); chrono.setBase(SystemClock.elapsedRealtime()); chrono.start(); chrono.setOnChronometerTickListener(new OnChronometerTickListener() { public void onChronometerTick(Chronometer arg0) { // TODO Auto-generated method stub long minutes = ((elapsedTime - chrono.getBase()) / 1000) / 60; long seconds = ((elapsedTime - chrono.getBase()) / 1000) % 60; currentTime = minutes + ":" + seconds; arg0.setText(currentTime); elapsedTime = elapsedTime + 1000; } }); } listView.invalidate(); </code></pre> <hr> <p><strong>What I'm doing wrong? Maybe there is <em>other solution</em> how to start chronometer in each row?</strong></p>
 

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