Android Open Source - Sliding Menu List Adapter

From Project

Back to project page


The source code is released under:

Apache License

If you think the Android project 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 nl.fhict.intellicloud.answers;
/*from   w w w .j  a  va  2s.c om*/
import java.text.SimpleDateFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import java.util.concurrent.TimeUnit;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SlidingMenuListAdapter extends ArrayAdapter<String> {
   private final Context context;
   private final String[] values;

    public SlidingMenuListAdapter(Context context, String[] values) {
      super(context, R.layout.listview_item_sliding_menu, values);
      this.context = context;
      this.values = values;

    public View getView(int position, View convertView, ViewGroup parent) {
      LayoutInflater inflater = (LayoutInflater) context
      View rowView = inflater.inflate(R.layout.listview_item_sliding_menu, parent, false);
      String drawerItem = values[position];
      ImageView questionStageImage = (ImageView) rowView.findViewById(;
      int imageId = getImageId(position);
      if (imageId != -1)
      TextView firstLine = (TextView) rowView.findViewById(;

      return rowView;
    private int getImageId(int drawerItemPosition) {
      switch(drawerItemPosition) {
        case 0:
          return R.drawable.all_icon_white;
      case 1:
        return R.drawable.guestion_icon_white;
      case 2:
          return R.drawable.rejected_icon_white;
      case 3:
          return R.drawable.hourglass_icon_white;
      case 4:
          return R.drawable.glass_icon_white;
      return -1;

Java Source Code List