public class TaskListActivity extends Activity implements OnItemClickListener
{
private TaskListAdapter adapter = null;
private ArrayList<Task> taskList = null;
private ListView list = null;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
setContentView(R.layout.task_list);
fillTaskList();
adapter = new TaskListAdapter(this, taskList);
list = (ListView) findViewById(R.id.task_listview);
list.setAdapter(adapter);
list.setOnItemClickListener(this);
list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
TaskListAdapter adp = (TaskListAdapter)parent.getAdapter();
Task task = adp.getItem(position);
System.out.print(task.getAddress());
Intent i = new Intent(view.getContext(), TaskActivity.class);
i.putExtra("task", task);
this.startActivity(i);
}
}
No comments:
Post a Comment