Android Open Source - AndroidForiOS Line Type Array Adapter






From Project

Back to project page AndroidForiOS.

License

The source code is released under:

MIT License

If you think the Android project AndroidForiOS 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 com.example.androidforios.app.adapters;
// w ww  .  j  av  a  2s . com
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.androidforios.app.data.model.TripList;

/**
 * An {@link android.widget.ArrayAdapter} which formats {@link com.example.androidforios.app.data.model.TripList.LineType}
 * subway line enumerated values into listview views based on {@code simple_list_item_1}.
 */
public class LineTypeArrayAdapter extends ArrayAdapter<TripList.LineType> {

    int LAYOUT_RESOURCE_ID = android.R.layout.simple_list_item_1;

    public LineTypeArrayAdapter(Context context, TripList.LineType[] objects) {
        super(context, android.R.layout.simple_list_item_1, objects);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        TripList.LineType lineType = this.getItem(position);
        View inflatedView = convertView;
        if(convertView==null)
        {
            LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            inflatedView = inflater.inflate(LAYOUT_RESOURCE_ID, null);
        }

        TextView title = (TextView)inflatedView.findViewById(android.R.id.text1);
        title.setText(lineType.getLineName());
        title.setTextColor(getContext().getResources().getColor(lineType.getLineColorResourceId()));

        return inflatedView;
    }
}




Java Source Code List

com.example.androidforios.app.activities.MainActivity.java
com.example.androidforios.app.activities.TripDetailActivity.java
com.example.androidforios.app.activities.TripListActivity.java
com.example.androidforios.app.adapters.LineTypeArrayAdapter.java
com.example.androidforios.app.adapters.PredictionArrayAdapter.java
com.example.androidforios.app.adapters.TripArrayAdapter.java
com.example.androidforios.app.data.managers.DataManager.java
com.example.androidforios.app.data.model.Prediction.java
com.example.androidforios.app.data.model.TripList.java
com.example.androidforios.app.data.model.Trip.java
com.example.androidforios.app.fragments.SubwayListFragment.java
com.example.androidforios.app.fragments.TripDetailFragment.java
com.example.androidforios.app.fragments.TripListFragment.java
com.example.androidforios.app.views.TripDetailsView.java