Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Got Answer by using the below code</p> <p>In mainActivity adapter class</p> <pre><code> adapter=new ArrayAdapter&lt;String&gt;(getApplicationContext(), R.layout.text_view,R.id.textView1,players); lvview.setAdapter(adapter); </code></pre> <p>main.xml look like below</p> <pre><code>&lt;ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="8.5" android:cacheColorHint="#00000000" /&gt; </code></pre> <p>And my custom layout field is like below</p> <pre><code>&lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginTop="23dp" android:text="TextView" android:textColor="#ffffff" /&gt; &lt;CheckBox android:id="@+id/checkBox1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/textView1" android:layout_alignBottom="@+id/textView1" android:layout_alignParentRight="true" android:focusable="false" android:focusableInTouchMode="false" /&gt; </code></pre> <p>And in MainActivity onitem click listener for ListView I called the custom layout view and the code is given below</p> <pre><code> lvview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; l, View v, int position, long id) { // TODO Auto-generated method stub SparseBooleanArray checked = lvview.getCheckedItemPositions(); checkedText=(CheckBox) v.findViewById(R.id.checkBox1); checkedList=(TextView) v.findViewById(R.id.textView1); if(checkedText.isChecked()==false) { counter_selected++; checkedText.setChecked(true); checkedList.setTextColor(Color.RED); selectedCounterText.setText("" + counter_selected); } else { counter_selected--; checkedText.setChecked(false); checkedList.setTextColor(Color.WHITE); selectedCounterText.setText("" + counter_selected); } } }); </code></pre> <p>And it solved my problem..</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