예제 #1
0
 public void onResume() {
   super.onResume();
   final ListView lv1 = (ListView) findViewById(R.id.listView1);
   lv1.setAdapter(new taskListAdapter(this, TaskArry.getInstance()));
 }
예제 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // GetSearchResults();
    final taskListAdapter adapter = new taskListAdapter(this, TaskArry.getInstance());
    final ListView lv1 = (ListView) findViewById(R.id.listView1);
    lv1.setAdapter(adapter);
    /*lv1.setOnLongClickListener(new OnLongClickListener()
    {

    	public boolean onLongClick(View v) {
    		// TODO Auto-generated method stub
    		return false;
    	}
    });*/
    lv1.setOnItemClickListener(
        new OnItemClickListener() {
          public void onItemClick(AdapterView<?> a, View v, int position, long id) {
            Object o = lv1.getItemAtPosition(position);
            TaskItem obj_taskItem = (TaskItem) o;
            Toast.makeText(
                    TaskListActivity.this,
                    "You have chosen : " + " " + obj_taskItem.getTaskName(),
                    Toast.LENGTH_LONG)
                .show();
          }
        });

    /*lv1.setOnTouchListener(new OnTouchListener()
    {

    	float historicX = Float.NaN;
    	final int TRIGGER_DELTA = 150;
    	Button bt = (Button) findViewById(R.id.delTask);
    	public boolean onTouch(View v, MotionEvent event)
    	{
    		switch (event.getAction())
    		{
    			case MotionEvent.ACTION_DOWN:
    				historicX = event.getX();
    		        break;
    			case  MotionEvent.ACTION_UP:
    				if ((event.getX() - historicX) < TRIGGER_DELTA)
    				{

    					bt.setVisibility(View.INVISIBLE);
    					adapter.notifyDataSetChanged();

    				}
    				else if ((event.getX() - historicX) > TRIGGER_DELTA)
    				{

    					bt.setVisibility(View.VISIBLE);
    					adapter.notifyDataSetChanged();

    				}
    				break;

    		}
    		return false;
    	}
    });*/

    Button addTask = (Button) findViewById(R.id.addTaskButtonMain);
    addTask.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            Intent intent = new Intent(v.getContext(), AddTaskActivity.class);
            startActivity(intent);
          }
        });
  }