package victory.sandbox.mytestapp;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import java.util.ArrayList;


public class MyActivity extends Activity {

    Button clickToList;
    ListView myListView;
    private ArrayAdapter<String> adapter;
    private ArrayList<String> arrayList;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);

        clickToList = (Button) findViewById(R.id.clickToList);
        myListView = (ListView) findViewById(R.id.listView);


        arrayList = new ArrayList<String>();

        adapter = new ArrayAdapter<String>(
                getApplicationContext(),
                R.layout.list_layout,
                R.id.listTextView,
                arrayList);

        myListView.setAdapter(adapter);

        clickToList.setOnClickListener(new View.OnClickListener() {
            private Integer counter = 0;
            private int maxClicks = 50;

            @Override
            public void onClick(View v) {
                if (counter >= maxClicks) {
                    return;
                }
                arrayList.add("Row: " + counter.toString());
                counter += 1;
                adapter.notifyDataSetChanged();
                myListView.setBackgroundColor(
                        getResources().getColor(android.R.color.background_dark));

            }
        });


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        return (id == R.id.action_settings) || (super.onOptionsItemSelected(item));
    }
}

@@ -162,24 +162,59 @@
 .view.View;%0A
+import android.widget.AdapterView;%0A
 import andro
@@ -237,16 +237,16 @@
 dapter;%0A
-
 import a
@@ -506,16 +506,622 @@
 yList;%0A%0A
+    private class SwipeListener implements AdapterView.OnItemClickListener %7B%0A        private SwipeDetector swipeDetector = null;%0A%0A        @Override%0A        public void onItemClick(AdapterView%3C?%3E parent, View view, int position, long id) %7B%0A            if (swipeDetector == null) %7B%0A                return;%0A            %7D%0A            swipeDetector.getSwipeHorizontal();%0A        %7D%0A%0A        public void setSwipeDetector(SwipeDetector swipeDetector) %7B%0A            this.swipeDetector = swipeDetector;%0A        %7D%0A%0A        public SwipeDetector getSwipeDetector () %7B%0A            return swipeDetector;%0A        %7D%0A    %7D%0A%0A
 %0A    @Ov
@@ -1396,24 +1396,276 @@
 listView);%0A%0A
+        SwipeListener swipeListener = new SwipeListener();%0A        swipeListener.setSwipeDetector(new SwipeDetector());%0A%0A        myListView.setOnItemClickListener(swipeListener);%0A        myListView.setOnTouchListener(swipeListener.getSwipeDetector());%0A
 %0A        arr

attach the listener swipe listeners