@Override protected void onCreate(Bundle savedInstanceState) { // Initialize and set the content view super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListData.initializeListData(); // Store local reference to the ListView theListView = (ListView) findViewById(android.R.id.list); // Populate local ArrayLists titleList = ListData.getTitleList(); infoList = ListData.getInfoList(); completedList = ListData.getCompletedList(); // Create adapter to dynamically pass strings to the view SpecialAdapter listAdapter = new SpecialAdapter(this, R.layout.list_layout, titleList); setListAdapter(listAdapter); // Set on click listener to generate an intent and launch new activity theListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Log.i("Item Click", "Position: " + position + "id: " + id); String clickedText = (String) parent.getItemAtPosition(position); ListData.setIndexLastClicked(position); Intent intent = new Intent(MainActivity.this, InfoPage.class); intent.putExtra(INDEX_MESSAGE, position); startActivity(intent); } }); // Long click listener used to complete/reset items from the main list view theListView.setOnItemLongClickListener( new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Log.i("Item Long Click", "Position: " + position + "id: " + id); boolean completed = ListData.getCompletedList().get(position); RelativeLayout l = (RelativeLayout) view; TextView v = (TextView) l.getChildAt(0); TextView w = (TextView) l.getChildAt(1); Log.i("Children", "v:" + v.getText().toString() + " w: " + w.getText().toString()); if (completed) { // Reset ListData.setCompleted(position, false); v.setTextColor(Color.BLACK); w.setText("\u2705"); w.setTextColor(Color.LTGRAY); } else { // Complete ListData.setCompleted(position, true); v.setTextColor(Color.LTGRAY); w.setText("DONE!"); w.setTextColor(Color.parseColor("#73e600")); } return true; } }); }