title: where should i implement click function help me with code
body: <pre><code>public class ListViewMainActivity extends ListActivity {
  
  // declare class variables
  private ArrayList&lt;Item&gt; m_parts = new ArrayList&lt;Item&gt;();
  private Runnable viewParts;
  private ItemAdapter m_adapter;
  Dbhelper mydb =new Dbhelper(this);
  ArrayList&lt;Item&gt; abc = new ArrayList&lt;Item&gt;();;
  
  
  /** Called when the activity is first created. */
  public void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
  
      // instantiate our ItemAdapter class
      m_adapter = new ItemAdapter(this, R.layout.list_item, abc);
      setListAdapter(m_adapter);
  
      // here we are defining our runnable thread.
      viewParts = new Runnable(){
          public void run(){
              handler.sendEmptyMessage(0);
          }
      };
  
      // here we call the thread we just defined - it is sent to the handler below.
      Thread thread =  new Thread(null, viewParts, "MagentoBackground");
      thread.start();
  }
  
  private Handler handler = new Handler()
   {
      public void handleMessage(Message msg)
      {
          // create some objects
          // here is where you could also request data from a server
          // and then create objects from that data.
  
          abc = mydb.getweek();
          m_adapter = new ItemAdapter(ListViewMainActivity.this, R.layout.list_item, abc);
  
      // display the list.
      setListAdapter(m_adapter);
      }
  };
  </code></pre>
  
  <p>}</p>
  
  <p>Adapter code:</p>
  
  <pre><code>package com.example.myexpenses;
  
  import java.util.ArrayList;
  </code></pre>
  
  <p>public class ItemAdapter extends ArrayAdapter {</p>
  
  <pre><code>// declaring our ArrayList of items
  private ArrayList&lt;Item&gt; objects;
  Context context;
  /* here we must override the constructor for ArrayAdapter
  * the only variable we care about now is ArrayList&lt;Item&gt; objects,
  * because it is the list of objects we want to display.
  */
  public ItemAdapter(Context context, int textViewResourceId, ArrayList&lt;Item&gt; objects) {
      super(context, textViewResourceId, objects);
      this.context = context;
      this.objects = objects;
  }
  
  /*
   * we are overriding the getView method here - this is what defines how each
   * list item will look.
   */
  public View getView(int position, View convertView, ViewGroup parent){
  
      // assign the view we are converting to a local variable
      View v = convertView;
  
      // first check to see if the view is null. if so, we have to inflate it.
      // to inflate it basically means to render, or show, the view.
      if (v == null) 
  </code></pre>
  
  <p>{
                         LayoutInflater inflater = (LayoutInflater)           getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              v = inflater.inflate(R.layout.list_item, null);
          }</p>
  
  <pre><code>    Item i = objects.get(position);
  
      if (i != null) {
  
          // This is how you obtain a reference to the TextViews.
          // These TextViews are created in the XML files we defined.
  
          TextView ttd = (TextView) v.findViewById(R.id.toptextdata);
  
          TextView mtd = (TextView) v.findViewById(R.id.middletextdata);
          TextView bt = (TextView) v.findViewById(R.id.bottomtext);
  
          // check to see if each individual textview is null.
          // if not, assign some text!
  
          if (ttd != null){
              ttd.setText(i.getName());
          }
  
          if (mtd != null){
              mtd.setText("$" + i.getPrice());
          }
  
          if (bt != null){
              bt.setText(i.getDetails());
          }
      }
  
      // the view must be returned to our activity
      return v;
  
  }
  </code></pre>
  
  <p>}</p>