Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate TextView within custom ListView
    text
    copied!<p>I'm trying to update the TextView within a custom ListView at a set time interval, for example the TextView will update every 200ms however I can't figure out how to do this. The object updates with a number internally and I would like to show that in the mTitleText Textview however as the code below shows at the moment I can only achieve it when the user presses a button.</p> <pre><code>public class ListAdapter extends BaseAdapter { private ArrayList&lt; Object &gt; mObjects; private int mNumObjs = 0; private LayoutInflater mLayoutInflater; private Context mContext; public ListAdapter ( Context context, ArrayList&lt; Object &gt; objects ) { mObjects;= objects; mLayoutInflater = LayoutInflater.from(context); mContext = context; } public int getCount() { return mObjects;.size(); } public Object getItem( int position ) { return mObjects;.get(position); } public long getItemId( int position ) { return position; } public void addObject( Object obj) { obj.setId(mNumObjs); mObjects.add( obj ); (mNumObjs);++; notifyDataSetChanged(); } public void deleteObject( int pos ) { mObjects;.remove( pos ); notifyDataSetChanged(); } public View getView( final int position, View convertView, ViewGroup parent ) { final TimerView holder; if( convertView == null ) { convertView = mLayoutInflater.inflate( R.layout.customlistview, null ); holder = new HolderView(); holder.mListPosition = position; holder.mDeleteButton = (Button)convertView.findViewById(R.id.Delete); holder.mDeleteButton.setText( "Button No: " + position ); holder.mDeleteButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub deleteObject(holder.mListPosition); } }); holder.mButton = (Button)convertView.findViewById(R.id.Button); holder.mButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Object obj = mObjects.get(holder.mListPosition); mTitleText.setText(obj.getNum()); } }); convertView.setTag(holder); } else { holder = (TimerView) convertView.getTag(); } holder.mListPosition = position; holder.mDeleteButton.setText( "Button No: " + position ); return convertView; } class HolderView{ int mListPosition; Button mDeleteButton; Button mButton; TextView mTitleText; } } </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