List view with toggle button
<p>I am writing an application something like list view with toggle button.
Here is my source code. </p>

<pre><code>   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     ArrayAdapter&lt;String&gt; adapter=new ArrayAdapter&lt;String&gt;(getApplicationContext(),R.layout.main,R.id.textView1,getResources().getStringArray(R.array.Strings));
     setListAdapter(adapter);

   }

 @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
  String item = (String) getListAdapter().getItem(position);
  Toast.makeText(this, item+" selected", Toast.LENGTH_LONG).show();
}
</code></pre>

<p>And I am importing the list from string resources, and my sring.xml is
      
       MyListViewWithToggleButton
      Hello world!
      Settings
      MyListViewWithToggle
      ON/OFF</p>

<pre><code>  &lt;string-array name="Strings"&gt;

   &lt;item &gt;Relay1&lt;/item&gt;
  &lt;item &gt;Relay2&lt;/item&gt;
  &lt;item &gt;Relay3&lt;/item&gt;
  &lt;item &gt;Relay4&lt;/item&gt;
  &lt;item &gt;Relay5&lt;/item&gt;
  &lt;item &gt;Relay6&lt;/item&gt;
  &lt;item &gt;Relay7&lt;/item&gt;
  &lt;item &gt;Relay8&lt;/item&gt;
  &lt;/string-array&gt;
  &lt;/resources&gt;
</code></pre>

<p>And in mu main.xml I am using a text view and toggle button</p>

<pre><code>   &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
   android:layout_height="match_parent" &gt;

   &lt;TextView
     android:id="@+id/textView1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentLeft="true"
     android:layout_toLeftOf="@+id/toggleButton1"
     android:textSize="20dp" &gt;
  &lt;/TextView&gt;   


  &lt;ToggleButton
     android:id="@+id/toggleButton1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
     android:layout_marginLeft="4dp"
     android:layout_marginRight="10dp"
      android:text="@string/On_Off" &gt;

      &lt;/ToggleButton&gt;


       &lt;/RelativeLayout&gt;
</code></pre>

<p>when I click the toggle button it showing On and off.
But when I click on the list I am not getting any responses.</p>

<p>For my application I need to send some data while pressing the toggle button with respect to button condition.</p>
