Back to project page MixtioMD1Studio.
The source code is released under:
Apache License
If you think the Android project MixtioMD1Studio listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * Copyright 2014 Mixtio Software LLC//from ww w . j a v a 2 s . c o m * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * */ package com.mixtio.md1studio; import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import java.util.List; /** * Adapter used to build the ListView with a custom layout. * * @author Roger O'Dell */ public class ItemAdapter extends ArrayAdapter<SquareModel> { /**List variable of the SquareModel*/ private final List<SquareModel> mList; /**Variable for Activity*/ private final Activity mContext; /**Constructor*/ public ItemAdapter(Activity context, List<SquareModel> model) { super(context, R.layout.item_list_layout, model); mList = model; mContext = context; } @Override public View getView(int position, View convertView, ViewGroup parent) { View view = null; if(convertView == null) { LayoutInflater inflater = mContext.getLayoutInflater(); view = inflater.inflate(R.layout.item_list_layout, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.mImage = (ImageView)view.findViewById(R.id.iv_list_color); viewHolder.mLabel = (TextView)view.findViewById(R.id.tv_list_title); viewHolder.mRelative = (RelativeLayout)view.findViewById(R.id.rl_list); view.setTag(viewHolder); } else { view = convertView; } ViewHolder myHolder = (ViewHolder)view.getTag(); int resId = Utilities.getImageId(mContext.getApplicationContext(), mList.get(position).getImage()); myHolder.mLabel.setText(mList.get(position).getColor()); myHolder.mImage.setImageResource(resId); return view; } /**ViewHolder pattern*/ static class ViewHolder { protected TextView mLabel; protected ImageView mImage; protected RelativeLayout mRelative; } }