Android Open Source - Labs-HandHeld-Systems To Do List Adapter






From Project

Back to project page Labs-HandHeld-Systems.

License

The source code is released under:

Apache License

If you think the Android project Labs-HandHeld-Systems listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package course.labs.todomanager;
/*from w  ww .  jav  a  2 s . com*/
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ToDoListAdapter extends BaseAdapter {

  private final List<ToDoItem> mItems = new ArrayList<ToDoItem>();
  private final Context mContext;

  private static final String TAG = "Lab-UserInterface";

  public ToDoListAdapter(Context context) {

    mContext = context;

  }

  // Add a ToDoItem to the adapter
  // Notify observers that the data set has changed

  public void add(ToDoItem item) {

    mItems.add(item);
    notifyDataSetChanged();

  }

  // Clears the list adapter of all items.

  public void clear() {

    mItems.clear();
    notifyDataSetChanged();

  }

  // Returns the number of ToDoItems

  @Override
  public int getCount() {

    return mItems.size();

  }

  // Retrieve the number of ToDoItems

  @Override
  public Object getItem(int pos) {

    return mItems.get(pos);

  }

  // Get the ID for the ToDoItem
  // In this case it's just the position

  @Override
  public long getItemId(int pos) {

    return pos;

  }

  // Create a View for the ToDoItem at specified position
  // Remember to check whether convertView holds an already allocated View
  // before created a new View.
  // Consider using the ViewHolder pattern to make scrolling more efficient
  // See: http://developer.android.com/training/improving-layouts/smooth-scrolling.html
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    // TODO - Get the current ToDoItem
    final ToDoItem toDoItem = null;

    // TODO - Inflate the View for this ToDoItem
    // from todo_item.xml
    RelativeLayout itemLayout = null;

    // TODO - Fill in specific ToDoItem data
    // Remember that the data that goes in this View
    // corresponds to the user interface elements defined
    // in the layout file

    // TODO - Display Title in TextView
    final TextView titleView = null;

    // TODO - Set up Status CheckBox
    final CheckBox statusView = null;

    statusView.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      @Override
      public void onCheckedChanged(CompoundButton buttonView,
          boolean isChecked) {
        Log.i(TAG, "Entered onCheckedChanged()");

        // TODO - set up an OnCheckedChangeListener, which
        // is called when the user toggles the status checkbox

      }
    });

    // TODO - Display Priority in a TextView

    final TextView priorityView = null;

    // TODO - Display Time and Date.
    // Hint - use ToDoItem.FORMAT.format(toDoItem.getDate()) to get date and
    // time String

    final TextView dateView = null;

    // Return the View you just created
    return itemLayout;

  }
}




Java Source Code List

course.labs.activitylab.ActivityOne.java
course.labs.activitylab.ActivityTwo.java
course.labs.dangerousapp.DangerousActivity.java
course.labs.fragmentslab.FeedFragmentData.java
course.labs.fragmentslab.FeedFragment.java
course.labs.fragmentslab.FriendsFragment.java
course.labs.fragmentslab.MainActivity.java
course.labs.intentslab.ActivityLoaderActivity.java
course.labs.intentslab.ExplicitlyLoadedActivity.java
course.labs.intentslab.mybrowser.MyBrowserActivity.java
course.labs.permissionslab.ActivityLoaderActivity.java
course.labs.permissionslab.BookmarksActivity.java
course.labs.permissionslab.GoToDangerousActivity.java
course.labs.todomanager.AddToDoActivity.java
course.labs.todomanager.ToDoItem.java
course.labs.todomanager.ToDoListAdapter.java
course.labs.todomanager.ToDoManagerActivity.java